From 77f25b4e9377bf63945324e1013143c64ce86d9e Mon Sep 17 00:00:00 2001 From: byeaxj Date: Thu, 9 May 2024 15:31:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Commit=20by:=20byeaxj=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 📝 Changes: M .obsidian/workspace.json M beiklive/.vuepress/config.ts M deploy.sh AM githubpush.py --- .obsidian/workspace.json | 8 +++---- beiklive/.vuepress/config.ts | 6 ++--- deploy.sh | 2 +- githubpush.py | 46 ++++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 githubpush.py diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index ec10fc36..e5bf0d4d 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -165,6 +165,10 @@ }, "active": "da9ca8a590533596", "lastOpenFiles": [ + "githubpush.py", + "githubpush.bat", + "githubpush copy.sh", + "githubpush.sh", "node_modules/gitalk/node_modules/date-fns/fp/lastDayOfQuarter/index.js", "node_modules/gitalk/node_modules/date-fns/fp/lastDayOfQuarter/package.json", "node_modules/gitalk/node_modules/date-fns/fp/lastDayOfQuarter/index.js.flow", @@ -172,10 +176,6 @@ "node_modules/gitalk/node_modules/date-fns/fp/lastDayOfQuarter", "node_modules/gitalk/node_modules/date-fns/fp/isWithinInterval/package.json", "node_modules/gitalk/node_modules/date-fns/fp/isWithinInterval/index.js.flow", - "node_modules/gitalk/node_modules/date-fns/fp/isWithinInterval/index.js", - "node_modules/gitalk/node_modules/date-fns/fp/isWithinInterval/index.d.ts", - "node_modules/gitalk/node_modules/date-fns/fp/isWithinInterval", - "node_modules/gitalk/node_modules/date-fns/esm/locale/uk/_lib/localize/index.js", "beiklive/Note_obsidian/01.插件推荐.md", "beiklive/02.记录/02.折腾记录/00.obsidian.md", "beiklive/02.记录/01.工具使用/01.Git.md", diff --git a/beiklive/.vuepress/config.ts b/beiklive/.vuepress/config.ts index 956597ee..0efb538f 100644 --- a/beiklive/.vuepress/config.ts +++ b/beiklive/.vuepress/config.ts @@ -19,7 +19,7 @@ export default defineConfig4CustomTheme({ '/': { lang: 'zh-CN', title: "beiklive's blog", - description: 'web前端技术博客,专注web前端学习与总结。JavaScript,js,ES6,TypeScript,vue,React,python,css3,html5,Node,git,github等技术文章。', + description: '懒狗的摸鱼日记', } }, base: '/vuepresswiki/', @@ -192,7 +192,7 @@ export default defineConfig4CustomTheme({ footer: { createYear: 2024, // 博客创建年份 copyrightInfo: - 'beiklive | MIT License', // 博客版权信息、备案信息等,支持a标签或换行标签
+ 'beiklive | 苏ICP备20038092号-2', // 博客版权信息、备案信息等,支持a标签或换行标签
}, // 扩展自动生成frontmatter。(当md文件的frontmatter不存在相应的字段时将自动添加。不会覆盖已有的数据。) @@ -214,7 +214,7 @@ export default defineConfig4CustomTheme({ 'meta', { name: 'keywords', - content: '前端博客,个人技术博客,前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown', + content: '后端博客,个人技术博客,C++,linux,qt,python,技术文档,学习,vue,python,css3,html5,Node,git,github,markdown', }, ], ['meta', { name: 'baidu-site-verification', content: '7F55weZDDc' }], // 百度统计的站长验证(你可以去掉) diff --git a/deploy.sh b/deploy.sh index 1a1791b0..1ee27c70 100644 --- a/deploy.sh +++ b/deploy.sh @@ -4,7 +4,7 @@ set -e -push_addr=https://github.com/beiklive/beiklive.github.io # git提交地址,也可以手动设置,比如:push_addr=git@github.com:xugaoyi/vuepress-theme-vdoing.git +push_addr=`git remote get-url --push origin` # git提交地址,也可以手动设置,比如:push_addr=git@github.com:xugaoyi/vuepress-theme-vdoing.git commit_info=`git describe --all --always --long` dist_path=beiklive/.vuepress/dist # 打包生成的文件夹路径 push_branch=gh-pages # 推送的分支 diff --git a/githubpush.py b/githubpush.py new file mode 100644 index 00000000..022d249d --- /dev/null +++ b/githubpush.py @@ -0,0 +1,46 @@ +import subprocess + +def get_git_user_info(): + # 获取用户姓名和邮箱 + user_name = subprocess.check_output(['git', 'config', 'user.name']).strip().decode() + user_email = subprocess.check_output(['git', 'config', 'user.email']).strip().decode() + return user_name, user_email + +def get_git_status(): + # 获取文件变更信息 + git_status = subprocess.check_output(['git', 'status', '--porcelain', '--untracked-files=all']).strip().decode() + return git_status + +def format_commit_message(user_name, user_email, diff_info): + # 构造提交信息 + commit_message = f"🚀 Commit by: {user_name} <{user_email}>\n\n" + commit_message += "📝 Changes:\n" + commit_message += diff_info + return commit_message + +def main(): + try: + # 获取用户姓名和邮箱 + user_name, user_email = get_git_user_info() + + # 获取文件变更信息 + diff_info = get_git_status() + + # 格式化提交信息 + final_commit_message = format_commit_message(user_name, user_email, diff_info) + + # 添加所有修改的文件到暂存区 + subprocess.run(['git', 'add', '-A']) + + # 提交到本地仓库 + subprocess.run(['git', 'commit', '-m', final_commit_message]) + + # 推送到远程仓库 + # subprocess.run(['git', 'push']) + + print("提交完成!") + except subprocess.CalledProcessError as e: + print(f"出现错误:{e}") + +if __name__ == "__main__": + main()