From 9bc9f9ea4ea3737e51e5f9448c991ba709667672 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 29 Sep 2021 21:30:10 -0700 Subject: [PATCH 1/2] 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. --- .github/workflows/authors.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/authors.yml b/.github/workflows/authors.yml index 04ca2772c0cf11..ed40c2e0a078b2 100644 --- a/.github/workflows/authors.yml +++ b/.github/workflows/authors.yml @@ -15,12 +15,23 @@ jobs: with: fetch-depth: '0' # This is required to actually get all the authors - run: "tools/update-authors.js" # Run the AUTHORS tool + - name: "Check for duplicates" + run: | + PATTERN_FILE=`mktemp`; + git diff | egrep '^\+[^+]' | perl -pe 's/^\+(.+?) <.+\n/\1\n/g' > $PATTERN_FILE; + 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 + echo 'DUPLICATES<> $GITHUB_ENV + if [ ! -z "${DUPLICATES}" ]; then + echo "The following may be duplicates; consider adding a .mailmap entry for them:" >> $GITHUB_ENV; + echo "${DUPLICATES}" >> $GITHUB_ENV; + fi; + echo 'EOF' >> $GITHUB_ENV; # Each line of duplicates starts with a space, so it won't conflict with 'EOF' - uses: gr2m/create-or-update-pull-request-action@v1 # Create a PR or update the Action's existing PR env: GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} with: author: Node.js GitHub Bot - 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." + 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}}" branch: "actions/authors-update" # Custom branch *just* for this Action. commit-message: "meta: update AUTHORS" labels: meta From ba782344ede851977e0bb86d961d8bfe9ec2c6fd Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 30 Sep 2021 07:02:46 -0700 Subject: [PATCH 2/2] fixup! build: check for duplicates in new AUTHORS entries --- .github/workflows/authors.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/authors.yml b/.github/workflows/authors.yml index ed40c2e0a078b2..e2195c9e73e96b 100644 --- a/.github/workflows/authors.yml +++ b/.github/workflows/authors.yml @@ -31,7 +31,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} with: author: Node.js GitHub Bot - 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}}" + 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 }}" branch: "actions/authors-update" # Custom branch *just* for this Action. commit-message: "meta: update AUTHORS" labels: meta