-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Only check the first 10 email addresses found in the PR | ||
EMAILS=$(git log $1 --pretty=format:"%ae" | sort | uniq | head -n 10) | ||
|
||
for EMAIL in $EMAILS ; do | ||
# Check if the email exists in the AUTHORS file | ||
if grep -Fq "$EMAIL" AUTHORS; then | ||
echo "Author's email is in the AUTHORS file." | ||
is_in_authors() { | ||
TARGET=$1 | ||
if grep -Fq "$TARGET" AUTHORS; then | ||
echo "Found $TARGET in AUTHORS" | ||
return 0 | ||
else | ||
# Post a comment on the PR | ||
COMMENT="Hello! Welcome and thank you for your contribution. It appears that you might be a new contributor to our project. To acknowledge your work appropriately, we kindly ask you to add your email to the AUTHORS file. This helps us maintain a record of all our valuable contributors. Thanks again for your involvement!" | ||
PAYLOAD=$(jq -n --arg body "$COMMENT" '{body: $body}') | ||
COMMENTS_URL=$(jq -r .pull_request.comments_url "$GITHUB_EVENT_PATH") | ||
echo "Could not find $TARGET in AUTHORS" | ||
return 1 | ||
fi | ||
} | ||
|
||
# Only check the first 10 committers found in the PR | ||
COMMITTERS=$(git log $1 --pretty=format:"%an;%ae" | sort | uniq | head -n 10) | ||
|
||
curl -s -S -H "Authorization: Bearer $GITHUB_TOKEN" --header "Content-Type: application/json" --data "$PAYLOAD" "$COMMENTS_URL" | ||
for COMMITTER in "$COMMITTERS" ; do | ||
# split sentence in two parts seperated by a ; | ||
NAME=$(echo $COMMITTER | cut -d ";" -f 1) | ||
EMAIL=$(echo $COMMITTER | cut -d ";" -f 2) | ||
|
||
if is_in_authors "$EMAIL" == 0 && is_in_authors "$NAME" == 0; then | ||
echo "This author is not found in the AUTHORS file" | ||
exit 1 | ||
fi | ||
done | ||
done | ||
|
||
echo "All authors are found in the AUTHORS file." | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ | |
# Please keep this list sorted alphabetically or run `python scripts/sort_authors.py` to auto-sort the authors list. | ||
|
||
Ahmed Ibrahim <[email protected]> | ||
Joshua Thijssen <[email protected]> | ||
|
||
Niklas Scheerhoorn <[email protected]> | ||
Zach Weaver <[email protected]> |