diff options
Diffstat (limited to 'evergreen/commit_message_validate.sh')
| -rw-r--r-- | evergreen/commit_message_validate.sh | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/evergreen/commit_message_validate.sh b/evergreen/commit_message_validate.sh index 45602695a95..6a66a2113cc 100644 --- a/evergreen/commit_message_validate.sh +++ b/evergreen/commit_message_validate.sh @@ -1,14 +1,25 @@ +# Note: This script is called "commit_message_validate", but it does not actually +# evaluate the commit message. Rather, it leverages the fact that a GitHub merge queue +# triggered branch will have a single commit message that is the name of the PR. +# This script ensures the PR name matches a well-known regex (see below for details). DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" . "$DIR/prelude.sh" - cd src - set -o verbose set -o errexit if [ "${is_commit_queue}" = "true" ]; then + # Fetch the gitlog from the last merge commit to HEAD, which is guaranteed + # to be the commit message of the PR. + gitlog=$(git log --pretty=format:'%s' ${branch_name}...HEAD 2>&1) + # In case there are any special characters that could cause issues (like "). To + # do this, we will write it out to a file, then read that file into a variable. + cat > commit_message.txt << END_OF_COMMIT_MSG +${gitlog} +END_OF_COMMIT_MSG + commit_message_content=$(cat commit_message.txt) activate_venv - $python -m pip --disable-pip-version-check install --upgrade cryptography==36.0.2 || exit 1 - $python buildscripts/validate_commit_message.py \ - --evg-config-file ./.evergreen.yml \ - ${version_id} + $python buildscripts/validate_commit_message.py "$commit_message_content" +else + echo "Not a commit queue PR, skipping commit message validation" + exit 0 fi |
