forked from trezor/trezor-firmware
-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_changelog.sh
executable file
·64 lines (51 loc) · 1.86 KB
/
check_changelog.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
base_branch=master
fail=0
subdirs="core core/embed/boardloader core/embed/bootloader core/embed/bootloader_ci legacy/bootloader legacy/firmware legacy/intermediate_fw python"
# $ignored_files is a newline-separated list of patterns for grep
# therefore there must not be empty lines at start or end
ignored_files="^core/src/apps/ethereum/networks.py$
^core/src/apps/ethereum/tokens.py$
^core/src/trezor/enums/.*
^core/src/trezor/messages.py$
^python/src/trezorlib/messages.py$"
changed_files=$(mktemp)
trap 'rm -- $changed_files' EXIT
git fetch origin "$base_branch"
check_feature_branch () {
for commit in $(git rev-list origin/$base_branch..)
do
if git log -n1 --format=%B "$commit" | grep -iFq "[no changelog]"; then
echo "Found [no changelog] in $commit, skipping."
continue
fi
git show --pretty=format: --name-only "$commit" | grep -v "$ignored_files" >> "$changed_files"
done
for subdir in $subdirs
do
echo "Checking $subdir"
files=$(grep "^$subdir/" "$changed_files")
if echo "$files" | grep . | grep -Fq -v .changelog.d; then
if ! echo "$files" | grep -Fq .changelog.d; then
fail=1
echo "FAILURE! No changelog entry for changes in $subdir."
fi
fi
done
}
check_release_branch () {
if git diff --name-only "origin/$base_branch..." | grep -Fq .changelog.d; then
fail=1
echo "FAILURE! Changelog fragments not allowed in release branch:"
git diff --name-only "origin/$base_branch..." | grep -F .changelog.d
fi
}
if echo "$CI_COMMIT_BRANCH" | grep -Eq "^(release|secfix)/"; then
check_release_branch
else
check_feature_branch
fi
if [[ "$fail" -ne 0 ]]; then
echo "Please see https://docs.trezor.io/trezor-firmware/misc/changelog.html for instructions."
fi
exit $fail