From 6669c27376766fc79ac4ad27c3ad2b59320e5740 Mon Sep 17 00:00:00 2001 From: Eric Van Norman Date: Wed, 16 Jun 2021 16:37:32 -0500 Subject: [PATCH] Update to use first commit's parent sha to find file differences --- tools/check_release_notes.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/check_release_notes.sh b/tools/check_release_notes.sh index c651d31b9fb..a0e9bd438b6 100755 --- a/tools/check_release_notes.sh +++ b/tools/check_release_notes.sh @@ -72,7 +72,7 @@ get_opts() { shift 2 ;; --base-sha) - PULL_BASE_SHA="$2" + base_sha="$2" shift 2 ;; --pr-head-sha) @@ -122,11 +122,6 @@ validate_opts() { exit 1 fi - if [ -z "${PULL_BASE_SHA:-}" ]; then - echo "PULL_BASE_SHA not specified. This must match the base SHA for the pull request." - exit 1 - fi - if [ -z "${REPO_PATH:-}" ]; then echo "REPO_PATH not specified. Using current working directory." REPO_PATH=$(pwd) @@ -134,12 +129,17 @@ validate_opts() { echo "Using REPO_PATH ${REPO_PATH}" fi + if [ -z "${base_sha:-}" ]; then + echo "base-sha not specified. Calculating from the PULL_NUMBER" + base_sha=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/"${REPO_OWNER}"/"${REPO_NAME}"/pulls/"${PULL_NUMBER}"/commits | jq -r '.[0].parents[0].sha') + echo "base_sha: ""${base_sha}""" + fi } # Curl the GitHub API to get a list of files for the specified PR. If files are # found, exit. We might eventually want to validate the data here. checkForFiles() { - echo "Checking files from pull request ${REPO_OWNER}/${REPO_NAME}#${PULL_NUMBER} head SHA: ${PULL_PULL_SHA} destination branch: ${PULL_BASE_REF}, base SHA: ${PULL_BASE_SHA}" + echo "Checking files from pull request ${REPO_OWNER}/${REPO_NAME}#${PULL_NUMBER} head SHA: ${PULL_PULL_SHA} destination branch: ${PULL_BASE_REF}, base SHA: ${base_sha}" pushd "${REPO_PATH}" @@ -149,7 +149,7 @@ checkForFiles() { popd set +e - "${GEN_RELEASE_NOTES_PATH}"/gen-release-notes --oldBranch "${PULL_BASE_SHA}" --newBranch "${PULL_PULL_SHA}" --templates "${GEN_RELEASE_NOTES_PATH}"/templates --notes ./releasenotes/notes --validateOnly + "${GEN_RELEASE_NOTES_PATH}"/gen-release-notes --oldBranch "${base_sha}" --newBranch "${PULL_PULL_SHA}" --templates "${GEN_RELEASE_NOTES_PATH}"/templates --notes ./releasenotes/notes --validateOnly returnCode=$? set -e @@ -183,7 +183,7 @@ function validateNotes() { popd local errorOccurred=0 - git diff-tree -r --diff-filter=AMR --name-only --relative=releasenotes/notes "${PULL_BASE_SHA}" "${PULL_PULL_SHA}" | \ + git diff-tree -r --diff-filter=AMR --name-only --relative=releasenotes/notes "${base_sha}" "${PULL_PULL_SHA}" | \ { set +e while read -r line; do