From 0cc6bc0f1d17d690fbf85b48f8ae6767fcde3d23 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 2 Apr 2023 21:02:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dupdate=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/command/command.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/model/command/command.py b/model/command/command.py index 43fdb1a34..d2e41b3fe 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -24,13 +24,18 @@ class Command: # 得到当前commit hash repo = Repo() commit = repo.head.commit - # 得到最新的5条commit列表 + # 得到最新的5条commit列表, 包含commit信息 origin = repo.remotes.origin origin.fetch() - commits = list(origin.refs.master.log())[0:5] - remote_commit_hash = origin.refs.master.commit.hexsha + commits = list(repo.iter_commits('master', max_count=5)) + commits_log = '' + index = 1 + for commit in commits: + commits_log += f"[{index}] {commit.message}\n-----------\n" + index+=1 + remote_commit_hash = origin.refs.master.commit.hexsha[:6] - return True, f"当前版本: {commit.hexsha}\n最新版本: {remote_commit_hash}\n\n最新5条commit:{str(commits)}\n\n使用update latest更新至最新版本\n" + return True, f"当前版本: {commit.hexsha[:6]}\n最新版本: {remote_commit_hash}\n\n最新5条commit:\n{str(commits_log)}\n使用update latest更新至最新版本\n" else: if l[1] == "latest": try: