post-merge 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. red="$(tput setaf 1)"
  3. yellow="$(tput setaf 3)"
  4. bold="$(tput bold)"
  5. reset="$(tput sgr0)"
  6. files_changed_upstream="$(mktemp)"
  7. # shellcheck disable=SC2064
  8. trap "rm -f $files_changed_upstream" EXIT
  9. git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD >"$files_changed_upstream"
  10. if grep --quiet 'requirements-dev-frozen.txt' "$files_changed_upstream" || grep --quiet 'yarn.lock' "$files_changed_upstream" || grep --quiet 'migrations' "$files_changed_upstream"; then
  11. cat <<EOF
  12. [${red}${bold}!!!${reset}] ${red} It looks like some dependencies have changed. Run devenv sync to resync your environment.${reset}
  13. EOF
  14. if [[ "$SENTRY_POST_MERGE_AUTO_UPDATE" ]]; then
  15. echo "${yellow}Automatically running devenv sync because SENTRY_POST_MERGE_AUTO_UPDATE is set.${reset}"
  16. if ! command -v devenv >/dev/null 2>&1; then
  17. echo "devenv not found! install: https://github.com/getsentry/devenv#install"
  18. exit 1
  19. fi
  20. devenv sync
  21. else
  22. echo "${yellow}If you want devenv sync to be executed automatically after pulling code, you can export the SENTRY_POST_MERGE_AUTO_UPDATE variable.${reset}"
  23. fi
  24. fi