check-newsfragment 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. #
  3. # A script which checks that an appropriate news file has been added on this
  4. # branch.
  5. set -e
  6. # make sure that origin/develop is up to date
  7. git remote set-branches --add origin develop
  8. git fetch -q origin develop
  9. pr="$BUILDKITE_PULL_REQUEST"
  10. # if there are changes in the debian directory, check that the debian changelog
  11. # has been updated
  12. if ! git diff --quiet FETCH_HEAD... -- debian; then
  13. if git diff --quiet FETCH_HEAD... -- debian/changelog; then
  14. echo "Updates to debian directory, but no update to the changelog." >&2
  15. exit 1
  16. fi
  17. fi
  18. # if there are changes *outside* the debian directory, check that the
  19. # newsfragments have been updated.
  20. if ! git diff --name-only FETCH_HEAD... | grep -qv '^debian/'; then
  21. exit 0
  22. fi
  23. tox -qe check-newsfragment
  24. echo
  25. echo "--------------------------"
  26. echo
  27. matched=0
  28. for f in `git diff --name-only FETCH_HEAD... -- changelog.d`; do
  29. # check that any modified newsfiles on this branch end with a full stop.
  30. lastchar=`tr -d '\n' < $f | tail -c 1`
  31. if [ $lastchar != '.' -a $lastchar != '!' ]; then
  32. echo -e "\e[31mERROR: newsfragment $f does not end with a '.' or '!'\e[39m" >&2
  33. exit 1
  34. fi
  35. # see if this newsfile corresponds to the right PR
  36. [[ -n "$pr" && "$f" == changelog.d/"$pr".* ]] && matched=1
  37. done
  38. if [[ -n "$pr" && "$matched" -eq 0 ]]; then
  39. echo -e "\e[31mERROR: Did not find a news fragment with the right number: expected changelog.d/$pr.*.\e[39m" >&2
  40. exit 1
  41. fi