diff --git a/utils/sv_update_utils.py b/utils/sv_update_utils.py index 543a712877..2aa50c342f 100644 --- a/utils/sv_update_utils.py +++ b/utils/sv_update_utils.py @@ -221,27 +221,35 @@ class SvPrintCommits(bpy.types.Operator): bl_idname = "node.sv_show_latest_commits" bl_label = "Show latest commits" commits_link: bpy.props.StringProperty(default=COMMITS_LINK) + num_commits: bpy.props.IntProperty(default=30) def execute(self, context): r = requests.get(self.commits_link) json_obj = r.json() - for i in range(5): + + rewrite_date = lambda date: f'{date[:10]}' # @ {date[11:16]}' + + # table boilerplate for github markdown + print("author | commit details\n--- | ---") + + # intro message for Info printing + messages = [f"The {self.num_commits} most recent commits to Sverchok (master)"] + + for i in range(self.num_commits): commit = json_obj[i]['commit'] - comment = commit['message'].split('\n') + sha = os.path.basename(commit['url'])[:7] - # display on report window - message_dict = { - 'sha': os.path.basename(json_obj[i]['commit']['url'])[:7], - 'user': commit['committer']['name'], - 'comment': comment[0] + '...' if len(comment) else '' - } + author = commit['author']['name'] + date = commit['author']['date'] # format : '2021-04-03T10:44:59Z' + comments = commit['message'].split('\n') + comment = comments[0] + '...' if len(comments) else '' - self.report({'INFO'}, '{sha} : by {user} : {comment}'.format(**message_dict)) + message = f'{author} | {comment} {sha} on {rewrite_date(date)}' + print(message) + messages.append(message) - # display on terminal - print('{sha} : by {user}'.format(**message_dict)) - for line in comment: - print(' ' + line) + multiline_string_of_messages = "\n".join(messages) + self.report({'INFO'}, multiline_string_of_messages) return {'FINISHED'}