summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRod Vagg <rod@vagg.org>2018-11-23 12:55:28 +1100
committerRich Trott <rtrott@gmail.com>2018-11-30 23:09:41 -0800
commit76faccccbb51bb477a88ebfa3fa2a8254da37696 (patch)
tree25e40b36bb5b39df5122867d9c29b23ad5241bca /tools
parentf34ca9f783ec84391f22728fc150d7b7cc294968 (diff)
downloadandroid-node-v8-76faccccbb51bb477a88ebfa3fa2a8254da37696.tar.gz
android-node-v8-76faccccbb51bb477a88ebfa3fa2a8254da37696.tar.bz2
android-node-v8-76faccccbb51bb477a88ebfa3fa2a8254da37696.zip
tools: don't use GH API for commit message checks
Fixes: https://github.com/nodejs/node/issues/24567 PR-URL: https://github.com/nodejs/node/pull/24574 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/lint-pr-commit-message.sh28
1 files changed, 11 insertions, 17 deletions
diff --git a/tools/lint-pr-commit-message.sh b/tools/lint-pr-commit-message.sh
index 1998026a16..01afd9bab5 100644
--- a/tools/lint-pr-commit-message.sh
+++ b/tools/lint-pr-commit-message.sh
@@ -25,21 +25,15 @@ if [ -z "${PR_ID}" ]; then
echo " e.g. $0 <PR_NUMBER>"
exit 1
fi
-# Retrieve the first commit of the pull request via GitHub API
-# TODO: If we teach core-validate-commit to ignore "fixup!" and "squash!"
-# commits and lint messages for all commits in the pull request
-# we could simplify the following to:
-# npx -q core-validate-commit --no-validate-metadata ${GH_API_URL}/repos/nodejs/node/pulls/${PR_ID}/commits
-if PR_COMMITS="$( curl -s ${GH_API_URL}/repos/nodejs/node/pulls/${PR_ID}/commits )"; then
- if FIRST_COMMIT="$( node -p 'JSON.parse(process.argv[1])[0].url' "${PR_COMMITS}" 2> /dev/null )"; then
- echo "Linting the first commit message for pull request ${PR_ID}"
- echo "according to the guidelines at https://goo.gl/p2fr5Q."
- # Print the commit message to make it more obvious what is being checked.
- echo "Commit message for ${FIRST_COMMIT##*/} is:"
- node -p 'JSON.parse(process.argv[1])[0].commit.message' "${PR_COMMITS}" 2> /dev/null
- npx -q core-validate-commit --no-validate-metadata "${FIRST_COMMIT}"
- else
- echo "Unable to determine the first commit for pull request ${PR_ID}."
- exit 1
- fi
+
+PATCH=$( curl -sL https://github.com/nodejs/node/pull/${PR_ID}.patch | grep '^From ' )
+if FIRST_COMMIT="$( echo "$PATCH" | awk '/^From [0-9a-f]{40} / { if (count++ == 0) print $2 }' )"; then
+ MESSAGE=$( git show --quiet --format='format:%B' $FIRST_COMMIT )
+ echo "
+*** Linting the first commit message for pull request ${PR_ID}
+*** according to the guidelines at https://goo.gl/p2fr5Q.
+*** Commit message for $(echo $FIRST_COMMIT | cut -c 1-10) is:
+${MESSAGE}
+"
+ npx -q core-validate-commit --no-validate-metadata "${FIRST_COMMIT}"
fi