From a2846bb3bb11c40628ecf97f63717715a90a6932 Mon Sep 17 00:00:00 2001 From: Jason Yundt Date: Sat, 18 Feb 2023 08:29:58 -0500 Subject: [PATCH] Fix update-authors.py failing during pre-commit 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. --- update-authors.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/update-authors.py b/update-authors.py index dfeab0dcd..30c03ae40 100755 --- a/update-authors.py +++ b/update-authors.py @@ -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: +git_log = subprocess.check_output(['git', 'shortlog', '--summary', '--email', 'HEAD']) log_entries = git_log.decode('utf-8').strip().split('\n')