daml/ci/check-changelog.sh
Gary Verhaegen 89af1550b1
check for changelog (#3963)
* check for changelog
2020-01-07 17:19:50 +01:00

35 lines
815 B
Bash
Executable File

#!/usr/bin/env bash
# Copyright (c) 2020 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
contains_changelog () {
local awk_script="
BEGIN { flag = 0 }
toupper(\$0) ~ /CHANGELOG_BEGIN/ && flag == 0 { flag = 1 }
toupper(\$0) ~ /CHANGELOG_END/ && flag == 1 { flag = 2 }
END { print flag }
"
[[ 2 == $(git show -s --format=%B $1 | awk "$awk_script") ]]
}
for sha in $(git rev-list origin/master..); do
if contains_changelog $sha; then
echo "Commit $sha contains a changelog entry."
exit 0
fi
done
echo "
No changelog entry found; please add one. If your PR does not need a
changelog entry, please add an explicit, empty one, i.e. add
CHANGELOG_BEGIN
CHANGELOG_END
to your commit message.
"
exit 1