Skip to content

Commit

Permalink
Fix pre-commit-add-contributor hook for first time contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
giarve committed May 18, 2021
1 parent 476517b commit 0524afc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions githooks/pre-commit-add-contributor
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ else
if git log --pretty="%an%n%cn" | sort | uniq | grep -q "$(git config user.name)"; then
exit 0
else
printf "Please add yourself (copy the next line) to the CONTRIBUTORS.md file.\n";
printf '%s <%s>\n\n' "$(git config user.name)" "$(git config user.email)";
exit 1

expected=$(printf '%s <%s>' "$(git config user.name)" "$(git config user.email)");

if grep -q "$expected" CONTRIBUTORS; then
exit 0 # Already in the file but first time commit in the git history
else
echo "Please add yourself (copy the next line) to the CONTRIBUTORS.md file.";
echo $expected
exit 1
fi

fi
fi

0 comments on commit 0524afc

Please sign in to comment.