mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
🎨 优化更新插件相关命令的返回消息
This commit is contained in:
parent
2d3b0fcf77
commit
7dd8bc582a
@ -380,6 +380,15 @@ def update_from_git(
|
|||||||
|
|
||||||
logger.info(f'[更新] 准备更新 [{plugin_name}], 更新等级为{level}')
|
logger.info(f'[更新] 准备更新 [{plugin_name}], 更新等级为{level}')
|
||||||
|
|
||||||
|
# 先执行git fetch
|
||||||
|
logger.info(f'[更新][{plugin_name}] 正在执行 git fetch')
|
||||||
|
o.fetch()
|
||||||
|
|
||||||
|
default_branch_ref = repo.git.symbolic_ref('refs/remotes/origin/HEAD')
|
||||||
|
default_branch = default_branch_ref.split('/')[-1] # 提取主分支名称
|
||||||
|
|
||||||
|
commits_diff = list(repo.iter_commits(f'HEAD..origin/{default_branch}'))
|
||||||
|
|
||||||
if level >= 2:
|
if level >= 2:
|
||||||
logger.warning(f'[更新][{plugin_name}] 正在执行 git clean --xdf')
|
logger.warning(f'[更新][{plugin_name}] 正在执行 git clean --xdf')
|
||||||
logger.warning('[更新] 你有 2 秒钟的时间中断该操作...')
|
logger.warning('[更新] 你有 2 秒钟的时间中断该操作...')
|
||||||
@ -398,22 +407,30 @@ def update_from_git(
|
|||||||
logger.info(f'[更新][{repo.head.commit.hexsha[:7]}] 获取远程最新版本')
|
logger.info(f'[更新][{repo.head.commit.hexsha[:7]}] 获取远程最新版本')
|
||||||
except GitCommandError as e:
|
except GitCommandError as e:
|
||||||
logger.warning(f'[更新] 更新失败...{e}!')
|
logger.warning(f'[更新] 更新失败...{e}!')
|
||||||
return ['更新失败, 请检查控制台...']
|
return [f'更新插件 {plugin_name} 中...', '更新失败, 请检查控制台...']
|
||||||
|
|
||||||
commits = list(repo.iter_commits(max_count=40))
|
# commits = list(repo.iter_commits(max_count=40))
|
||||||
log_list = [f'更新插件 {plugin_name} 中...']
|
if commits_diff:
|
||||||
for commit in commits:
|
commits = commits_diff
|
||||||
if isinstance(commit.message, str):
|
else:
|
||||||
if log_key:
|
commits = []
|
||||||
for key in log_key:
|
log_list = []
|
||||||
if key in commit.message:
|
if commits:
|
||||||
log_list.append(commit.message.replace('\n', ''))
|
log_list.append(f'✅本次插件 {plugin_name} , 更新内容如下:')
|
||||||
if len(log_list) >= log_limit:
|
for commit in commits:
|
||||||
break
|
if isinstance(commit.message, str):
|
||||||
else:
|
if log_key:
|
||||||
log_list.append(commit.message.replace('\n', ''))
|
for key in log_key:
|
||||||
if len(log_list) >= log_limit:
|
if key in commit.message:
|
||||||
break
|
log_list.append(commit.message.replace('\n', ''))
|
||||||
|
if len(log_list) >= log_limit:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
log_list.append(commit.message.replace('\n', ''))
|
||||||
|
if len(log_list) >= log_limit:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
log_list.append(f'✅插件 {plugin_name} 本次无更新内容!')
|
||||||
return log_list
|
return log_list
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user