Skip to content

Commit

Permalink
Commit log printing (#4015)
Browse files Browse the repository at this point in the history
* update commit log printing

* -S

* streamline printing to report by appending messages

* consider adding date

* maybe needs more tweaks, but this is OK

* communicate what is being printed
  • Loading branch information
zeffii authored Apr 3, 2021
1 parent abadcd6 commit ff4d40f
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions utils/sv_update_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}

Expand Down

0 comments on commit ff4d40f

Please sign in to comment.