utils.sh 843 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # This library is meant to be used in bash, with "set -e" and "set -u".
  2. current_branch() {
  3. git branch | awk '/^\* / { print $2 }'
  4. }
  5. on_a_tag() {
  6. git describe --tags --exact-match $(git rev-parse --verify HEAD 2>/dev/null) >/dev/null 2>/dev/null
  7. }
  8. base_branch() {
  9. cat config/base_branch | head -n1
  10. }
  11. branch_name_to_suite() {
  12. local branch="$1"
  13. echo "$branch" | sed -e 's,[^.a-z0-9-],-,ig' | tr '[A-Z]' '[a-z]'
  14. }
  15. fatal() {
  16. echo "$*" >&2
  17. exit 1
  18. }
  19. git_tag_exists() {
  20. local tag="$1"
  21. test -n "$(git tag -l "$tag")"
  22. }
  23. version_was_released() {
  24. local version="$1"
  25. version="$(echo "$version" | tr '~' '-')"
  26. git_tag_exists "$version"
  27. }
  28. version_in_changelog() {
  29. dpkg-parsechangelog | awk '/^Version: / { print $2 }'
  30. }
  31. previous_version_in_changelog() {
  32. dpkg-parsechangelog --offset 1 --count 1 | awk '/^Version: / { print $2 }'
  33. }