Skip to content

Commit

Permalink
Fix update-authors.py failing during pre-commit
Browse files Browse the repository at this point in the history
Before this change, the pre-commit hook would always delete all of the
authors in the AUTHORS files. This was because update-authors.py would
get no output from the git shortlog command it ran which would result in
update-authors.py crashing with an AttributeError.
  • Loading branch information
Jayman2000 committed Jun 13, 2023
1 parent c6ecfe3 commit a2846bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion update-authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

author_re = re.compile(r'(?<=\t).*')

git_log = subprocess.check_output(['git', 'shortlog', '--summary', '--email'])
# Without the HEAD argument, git shortlog will fail when run during a pre-commit hook.
# Thanks to Michał Górny (https://stackoverflow.com/users/165333/micha%c5%82-g%c3%b3rny)
# for pointing this out: <https://stackoverflow.com/a/12133752/7593853>
git_log = subprocess.check_output(['git', 'shortlog', '--summary', '--email', 'HEAD'])
log_entries = git_log.decode('utf-8').strip().split('\n')


Expand Down

0 comments on commit a2846bb

Please sign in to comment.