Skip to content

Commit f409734

Browse files
authored
Merge pull request #1 from jorenverspeurt/master
Fix: first time commit
2 parents 1a2757f + ffc0f38 commit f409734

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

githooks/prepare-commit-msg

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,21 @@ def extract_jira_issue_key(message: str) -> Optional[str]:
3333
def last_commit_datetime() -> datetime.datetime:
3434
# https://git-scm.com/docs/git-log#_pretty_formats
3535
author = run_command('git config user.email')
36-
last_datetime = datetime.datetime.strptime(
37-
run_command(
38-
f'git log -1 --branches --format=%aI --author={author}'
39-
).split('+')[0],
40-
'%Y-%m-%dT%H:%M:%S') # %z
36+
last_author_stamp = run_command(
37+
f'git log -1 --branches --format=%aI --author={author}'
38+
)
39+
if '+' in last_author_stamp:
40+
last_datetime = datetime.datetime.strptime(
41+
last_author_stamp.split('+')[0],
42+
'%Y-%m-%dT%H:%M:%S'
43+
) # %z
44+
else:
45+
last_datetime = datetime.datetime.strptime(
46+
run_command(
47+
f'git log -1 --branches --format=%aI'
48+
).split('+')[0],
49+
'%Y-%m-%dT%H:%M:%S'
50+
) # %z
4151
return last_datetime
4252

4353

0 commit comments

Comments
 (0)