Skip to content

Commit

Permalink
改进更新日志的显示:支持显示日志开头的段落并限制分隔符最大宽度
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuukiy committed Dec 11, 2021
1 parent f92746a commit 8258536
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def print_header(title, info=[]):
info_width = max([get_actual_width(i) for i in info])
else:
info_width = 0
display_width = max(title_width, info_width) + 6
terminal_width = shutil.get_terminal_size().columns
display_width = min(max(title_width, info_width) + 6, terminal_width)
print('=' * display_width)
for line in title:
print(align_center(line, display_width))
Expand Down Expand Up @@ -168,12 +169,17 @@ def print_header(title, info=[]):
titles.append(release_url)
# 提取changelog消息
try:
lines = data['body'].split('\r\n')
enable_msg_head = True
lines = data['body'].splitlines()
changelog = [f'更新时间: {release_date}']
for line in lines:
if line.startswith('## '):
enable_msg_head = False
changelog.append(Style.BRIGHT + line[3:] + Style.RESET_ALL)
elif line.startswith('- '):
enable_msg_head = False
changelog.append(line)
elif enable_msg_head:
changelog.append(line)
print_header(titles, changelog)
except:
Expand Down

0 comments on commit 8258536

Please sign in to comment.