Skip to content

Commit ca00c2d

Browse files
authored
Merge pull request #114 from sopel-irc/commit-date
github: output relative committer & author date for commit URLs
2 parents d5281a3 + 7f7a695 commit ca00c2d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sopel_modules/github/github.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from sopel import tools
1616
from sopel.module import OP, NOLIMIT, commands, example, require_chanmsg, rule, url
1717
from sopel.formatting import bold, color, monospace
18-
from sopel.tools.time import get_timezone, format_time
18+
from sopel.tools.time import get_timezone, format_time, seconds_to_human
1919
from sopel.config.types import StaticSection, ValidatedAttribute
2020

2121
from .. import github as github_plugin
@@ -283,6 +283,10 @@ def commit_info(bot, trigger, match=None):
283283
if body.strip() == '':
284284
body = 'No commit message provided.'
285285

286+
now = datetime.datetime.utcnow() # can't use trigger.time until it becomes Aware in Sopel 8
287+
author_date = from_utc(data['commit']['author']['date'])
288+
committer_date = from_utc(data['commit']['committer']['date'])
289+
286290
change_count = data['stats']['total']
287291
file_count = len(data['files'])
288292
response = [
@@ -298,7 +302,11 @@ def commit_info(bot, trigger, match=None):
298302
' change' if change_count == 1 else ' changes',
299303
' in ',
300304
str(file_count),
301-
' file' if file_count == 1 else ' files'
305+
' file' if file_count == 1 else ' files',
306+
bold(' | '),
307+
'Authored ' + seconds_to_human((now - author_date).total_seconds()),
308+
bold(' | '),
309+
'Committed ' + seconds_to_human((now - committer_date).total_seconds()),
302310
]
303311
bot.say(''.join(response))
304312

0 commit comments

Comments
 (0)