@@ -25,21 +25,15 @@ if [ -z "${PR_ID}" ]; then
25
25
echo " e.g. $0 <PR_NUMBER>"
26
26
exit 1
27
27
fi
28
- # Retrieve the first commit of the pull request via GitHub API
29
- # TODO: If we teach core-validate-commit to ignore "fixup!" and "squash!"
30
- # commits and lint messages for all commits in the pull request
31
- # we could simplify the following to:
32
- # npx -q core-validate-commit --no-validate-metadata ${GH_API_URL}/repos/nodejs/node/pulls/${PR_ID}/commits
33
- if PR_COMMITS=" $( curl -s ${GH_API_URL} /repos/nodejs/node/pulls/${PR_ID} /commits ) " ; then
34
- if FIRST_COMMIT=" $( node -p ' JSON.parse(process.argv[1])[0].url' " ${PR_COMMITS} " 2> /dev/null ) " ; then
35
- echo " Linting the first commit message for pull request ${PR_ID} "
36
- echo " according to the guidelines at https://goo.gl/p2fr5Q."
37
- # Print the commit message to make it more obvious what is being checked.
38
- echo " Commit message for ${FIRST_COMMIT##*/ } is:"
39
- node -p ' JSON.parse(process.argv[1])[0].commit.message' " ${PR_COMMITS} " 2> /dev/null
40
- npx -q core-validate-commit --no-validate-metadata " ${FIRST_COMMIT} "
41
- else
42
- echo " Unable to determine the first commit for pull request ${PR_ID} ."
43
- exit 1
44
- fi
28
+
29
+ PATCH=$( curl -sL https://github.com/nodejs/node/pull/${PR_ID} .patch | grep ' ^From ' )
30
+ if FIRST_COMMIT=" $( echo " $PATCH " | awk ' /^From [0-9a-f]{40} / { if (count++ == 0) print $2 }' ) " ; then
31
+ MESSAGE=$( git show --quiet --format=' format:%B' $FIRST_COMMIT )
32
+ echo "
33
+ *** Linting the first commit message for pull request ${PR_ID}
34
+ *** according to the guidelines at https://goo.gl/p2fr5Q.
35
+ *** Commit message for $( echo $FIRST_COMMIT | cut -c 1-10) is:
36
+ ${MESSAGE}
37
+ "
38
+ npx -q core-validate-commit --no-validate-metadata " ${FIRST_COMMIT} "
45
39
fi
0 commit comments