Skip to content

Commit 3148f9b

Browse files
Trotttargos
authored andcommitted
build: check for duplicates in new AUTHORS entries
When the GitHub Action adds new entries to the AUTHORS file, have it also flag new entries that might be duplicates. PR-URL: #40264 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent f71ac57 commit 3148f9b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

.github/workflows/authors.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@ jobs:
1515
with:
1616
fetch-depth: '0' # This is required to actually get all the authors
1717
- run: "tools/update-authors.js" # Run the AUTHORS tool
18+
- name: "Check for duplicates"
19+
run: |
20+
PATTERN_FILE=`mktemp`;
21+
git diff | egrep '^\+[^+]' | perl -pe 's/^\+(.+?) <.+\n/\1\n/g' > $PATTERN_FILE;
22+
DUPLICATES=`grep -F -f $PATTERN_FILE AUTHORS | cut -d'<' -f1 | sort | uniq -c | sort -n | grep -v '^ *1 ' | perl -pe 's/^ *\d+ / /'`; # Last part here substitues a space at the start of each line
23+
echo 'DUPLICATES<<EOF' >> $GITHUB_ENV
24+
if [ ! -z "${DUPLICATES}" ]; then
25+
echo "The following may be duplicates; consider adding a .mailmap entry for them:" >> $GITHUB_ENV;
26+
echo "${DUPLICATES}" >> $GITHUB_ENV;
27+
fi;
28+
echo 'EOF' >> $GITHUB_ENV; # Each line of duplicates starts with a space, so it won't conflict with 'EOF'
1829
- uses: gr2m/create-or-update-pull-request-action@v1 # Create a PR or update the Action's existing PR
1930
env:
2031
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}
2132
with:
2233
author: Node.js GitHub Bot <[email protected]>
23-
body: "If this PR exists, there's presumably new additions to the AUTHORS file. This is an automatically generated PR by the `authors.yml` GitHub Action, which runs `tools/update-authors.js` and submits a new PR or updates an existing PR.\n\nPlease note that there might be duplicate entries. If there are, please remove them and add the duplicate emails to .mailmap directly to this PR."
34+
body: "Here are some new additions to the AUTHORS file. This is an automatically generated PR by the `authors.yml` GitHub Action, which runs `tools/update-authors.js`.\n\n{{ env.DUPLICATES }}"
2435
branch: "actions/authors-update" # Custom branch *just* for this Action.
2536
commit-message: "meta: update AUTHORS"
2637
labels: meta

0 commit comments

Comments
 (0)