From 7a04ef09856e0b3cc3ab01b223a74f58b083f3de Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Mon, 6 Mar 2023 11:04:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=AA=E5=90=AF=E5=8A=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=B8=8B=E7=9A=84=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20(#223)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 15 ++------------- pkg/utils/updater.py | 9 ++++++--- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index 0d130c9..3f24ac6 100644 --- a/main.py +++ b/main.py @@ -343,19 +343,8 @@ if __name__ == '__main__': sys.exit(0) elif len(sys.argv) > 1 and sys.argv[1] == 'update': - try: - try: - import pkg.utils.pkgmgr - pkg.utils.pkgmgr.ensure_dulwich() - except: - pass - - from dulwich import porcelain - - repo = porcelain.open_repo('.') - porcelain.pull(repo) - except ModuleNotFoundError: - print("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77") + import pkg.utils.updater as updater + updater.update_all() sys.exit(0) # import pkg.utils.configmgr diff --git a/pkg/utils/updater.py b/pkg/utils/updater.py index 84aa836..b365381 100644 --- a/pkg/utils/updater.py +++ b/pkg/utils/updater.py @@ -54,7 +54,7 @@ def get_current_tag() -> str: return current_tag -def update_all() -> bool: +def update_all(cli: bool=False) -> bool: """检查更新并下载源码""" current_tag = get_current_tag() @@ -124,8 +124,11 @@ def update_all() -> bool: f.write(current_tag) # 通知管理员 - import pkg.utils.context - pkg.utils.context.get_qqbot_manager().notify_admin("已更新到最新版本: {}\n更新日志:\n{}\n新功能通常可以在config-template.py中看到,完整的更新日志请前往 https://github.com/RockChinQ/QChatGPT/releases 查看".format(current_tag, "\n".join(rls_notes))) + if not cli: + import pkg.utils.context + pkg.utils.context.get_qqbot_manager().notify_admin("已更新到最新版本: {}\n更新日志:\n{}\n新功能通常可以在config-template.py中看到,完整的更新日志请前往 https://github.com/RockChinQ/QChatGPT/releases 查看".format(current_tag, "\n".join(rls_notes))) + else: + print("已更新到最新版本: {}\n更新日志:\n{}\n新功能通常可以在config-template.py中看到,完整的更新日志请前往 https://github.com/RockChinQ/QChatGPT/releases 查看".format(current_tag, "\n".join(rls_notes))) return True