Skip to content

Commit 0524afc

Browse files
committed
Fix pre-commit-add-contributor hook for first time contributors
1 parent 476517b commit 0524afc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

githooks/pre-commit-add-contributor

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ else
66
if git log --pretty="%an%n%cn" | sort | uniq | grep -q "$(git config user.name)"; then
77
exit 0
88
else
9-
printf "Please add yourself (copy the next line) to the CONTRIBUTORS.md file.\n";
10-
printf '%s <%s>\n\n' "$(git config user.name)" "$(git config user.email)";
11-
exit 1
9+
10+
expected=$(printf '%s <%s>' "$(git config user.name)" "$(git config user.email)");
11+
12+
if grep -q "$expected" CONTRIBUTORS; then
13+
exit 0 # Already in the file but first time commit in the git history
14+
else
15+
echo "Please add yourself (copy the next line) to the CONTRIBUTORS.md file.";
16+
echo $expected
17+
exit 1
18+
fi
19+
1220
fi
1321
fi

0 commit comments

Comments
 (0)