-
-
Notifications
You must be signed in to change notification settings - Fork 773
Expand file tree
/
Copy pathcheck_release_commit_messages.sh
More file actions
executable file
·33 lines (26 loc) · 953 Bytes
/
check_release_commit_messages.sh
File metadata and controls
executable file
·33 lines (26 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
fail=0
git fetch origin main
# list all commits between HEAD and main
for commit in $(git rev-list origin/main..)
do
message=$(git log -n1 --format=%B $commit)
echo "Checking $commit"
# The commit message must contain either
# 1. "cherry-picked from [some commit in main]"
if [[ $message =~ "(cherry picked from commit" ]]; then
# remove last ")" and extract commit hash
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
continue
fi
fi
# 2. [RELEASE ONLY] substring
if [[ $message =~ "[RELEASE ONLY]" ]]; then
continue
fi
fail=1
echo "FAILURE! Neither 'cherry picked from..' nor '[RELEASE ONLY]' substring found in this commit message."
done
exit $fail