2020-04-23 11:32:27 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
fail=0
|
|
|
|
|
2023-10-13 13:37:09 +00:00
|
|
|
git fetch origin main
|
2020-08-04 19:21:44 +00:00
|
|
|
|
2023-10-13 13:37:09 +00:00
|
|
|
# list all commits between HEAD and main
|
|
|
|
for commit in $(git rev-list origin/main..)
|
2020-04-23 11:32:27 +00:00
|
|
|
do
|
|
|
|
message=$(git log -n1 --format=%B $commit)
|
|
|
|
echo "Checking $commit"
|
|
|
|
|
|
|
|
# The commit message must contain either
|
2023-10-13 13:37:09 +00:00
|
|
|
# 1. "cherry-picked from [some commit in main]"
|
2020-04-23 11:32:27 +00:00
|
|
|
if [[ $message =~ "(cherry picked from commit" ]]; then
|
2020-06-07 19:49:06 +00:00
|
|
|
# remove last ")" and extract commit hash
|
2023-10-13 13:37:09 +00:00
|
|
|
main_commit=$(echo ${message:0:-1} | tr ' ' '\n' | tail -1)
|
|
|
|
# check if main really contains this commit hash
|
|
|
|
if [[ $(git branch -a --contains $main_commit | grep --only-matching "remotes/origin/main") == "remotes/origin/main" ]]; then
|
2020-04-23 11:32:27 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-11-05 18:11:02 +00:00
|
|
|
# 2. [RELEASE ONLY] substring
|
|
|
|
if [[ $message =~ "[RELEASE ONLY]" ]]; then
|
2020-04-23 11:32:27 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
fail=1
|
2020-11-05 18:11:02 +00:00
|
|
|
echo "FAILURE! Neither 'cherry picked from..' nor '[RELEASE ONLY]' substring found in this commit message."
|
2020-04-23 11:32:27 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
exit $fail
|