From f5a4b0494c85dec47786d2b6a22b40f34977f27b Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Thu, 3 Aug 2017 11:27:53 -0700 Subject: [PATCH] check_format: Make CHANGELOG.md update recommendations Notify users if they should consider updating CHANGELOG.md based on whether a file defining a public interface was modified. These are recommendations and are not fatal. Change-Id: I66d770917d86217325727411b292dad0582ed4e7 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/372560 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- scripts/check_format.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 6fc35b9e5..cbccd8842 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -91,4 +91,41 @@ if hash pep8; then rm -f pep8.log fi +# Check if any of the public interfaces were modified by this patch. +# Warn the user to consider updating the changelog any changes +# are detected. +echo -n "Checking whether CHANGELOG.md should be updated..." +staged=$(git diff --name-only --cached .) +working=$(git status -s --porcelain | grep -iv "??" | awk '{print $2}') +files="$staged $working" +if [[ "$files" = " " ]]; then + files=$(git diff-tree --no-commit-id --name-only -r HEAD) +fi + +has_changelog=0 +for f in $files; do + if [[ $f == CHANGELOG.md ]]; then + # The user has a changelog entry, so exit. + has_changelog=1 + break + fi +done + +needs_changelog=0 +if [ $has_changelog -eq 0 ]; then + for f in $files; do + if [[ $f == include/spdk/* ]] || [[ $f == scripts/rpc.py ]] || [[ $f == etc/* ]]; then + echo "" + echo -n "$f was modified. Consider updating CHANGELOG.md." + needs_changelog=1 + fi + done +fi + +if [ $needs_changelog -eq 0 ]; then + echo " OK" +else + echo "" +fi + exit $rc