Skip to content

Commit

Permalink
Merge pull request #1 from jorenverspeurt/master
Browse files Browse the repository at this point in the history
Fix: first time commit
  • Loading branch information
lsorber authored Jun 20, 2019
2 parents 1a2757f + ffc0f38 commit f409734
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions githooks/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,21 @@ def extract_jira_issue_key(message: str) -> Optional[str]:
def last_commit_datetime() -> datetime.datetime:
# https://git-scm.com/docs/git-log#_pretty_formats
author = run_command('git config user.email')
last_datetime = datetime.datetime.strptime(
run_command(
f'git log -1 --branches --format=%aI --author={author}'
).split('+')[0],
'%Y-%m-%dT%H:%M:%S') # %z
last_author_stamp = run_command(
f'git log -1 --branches --format=%aI --author={author}'
)
if '+' in last_author_stamp:
last_datetime = datetime.datetime.strptime(
last_author_stamp.split('+')[0],
'%Y-%m-%dT%H:%M:%S'
) # %z
else:
last_datetime = datetime.datetime.strptime(
run_command(
f'git log -1 --branches --format=%aI'
).split('+')[0],
'%Y-%m-%dT%H:%M:%S'
) # %z
return last_datetime


Expand Down

0 comments on commit f409734

Please sign in to comment.