Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d27b4ed

Browse files
committedAug 19, 2024··
fix: 修复异常返回错误代码
feat: 更新程序可以返回正常/错误代码 fix: 修改自动打包流触发器,避免重复触发
1 parent 654b385 commit d27b4ed

File tree

6 files changed

+19
-4
lines changed

6 files changed

+19
-4
lines changed
 

‎.github/workflows/build-linux.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches:
66
- main
7+
paths:
8+
# 仅在特定文件发生变化时触发
9+
- '**/中文git-pack.py'
10+
- '**/中文git更新程序.py'
711
workflow_dispatch:
812

913
jobs:

‎.github/workflows/build-macos.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches:
66
- main
7+
paths:
8+
# 仅在特定文件发生变化时触发
9+
- '**/中文git-pack.py'
10+
- '**/中文git更新程序.py'
711
workflow_dispatch:
812

913
jobs:

‎.github/workflows/build-windows.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches:
66
- main
7+
paths:
8+
# 仅在特定文件发生变化时触发
9+
- '**/中文git-pack.py'
10+
- '**/中文git更新程序.py'
711
workflow_dispatch:
812

913
jobs:

‎中文git-pack.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,4 @@ def git_command(command, *args):
649649
if auto_get_notice == "True":
650650
display_notice()# 自动公告获取
651651
exit_code = 1
652-
653-
exit_code = 1# 如果没有 __name__ == "__main__"
654652
sys.exit(exit_code)

‎中文git.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,4 @@ def git_command(command, *args):
645645
if auto_get_notice == "True":
646646
display_notice()# 自动公告获取
647647
exit_code = 1
648-
649-
exit_code = 1# 如果没有 __name__ == "__main__"
650648
sys.exit(exit_code)

‎中文git更新程序.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
init(autoreset=True)
88

9+
exit_code = 0
10+
911
def download_update_file(version):
12+
global exit_code
1013
# 根据版本确定下载 URL
1114
download_url = f'https://github.com/DuckDuckStudio/Chinese_git/releases/download/{version}/Chinese_git.exe'
1215
#spare_download_url = f'https://duckduckstudio.github.io/yazicbs.github.io/Tools/chinese_git/Spare-Download/Chinese_git.exe'
@@ -41,15 +44,18 @@ def download_update_file(version):
4144
# except Exception as e:
4245
# print(f"{Fore.RED}✕{Fore.RESET} 下载更新文件时出错: {e}")
4346
# return None
47+
exit_code = 1
4448
return None
4549

4650
def replace_current_program(new_filename):
51+
global exit_code
4752
try:
4853
# 用下载的文件替换当前程序
4954
os.replace(new_filename, os.path.join(os.path.dirname(sys.argv[0]), "中文git.exe"))
5055
print(f"{Fore.GREEN}{Fore.RESET} 程序已成功更新。")
5156
except Exception as e:
5257
print(f"{Fore.RED}{Fore.RESET} 替换当前程序时出错: {e}")
58+
exit_code = 1
5359

5460
if __name__ == "__main__":
5561
parser = argparse.ArgumentParser(description="打包版中文Git的更新程序")
@@ -61,3 +67,4 @@ def replace_current_program(new_filename):
6167
replace_current_program(new_filename)
6268

6369
input(f"按{Fore.BLUE}Enter{Fore.RESET}键退出...")
70+
sys.exit(exit_code)

0 commit comments

Comments
 (0)
Please sign in to comment.