post-merge 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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. if [ -f .venv/bin/devenv ]; then
  16. DEVENV=.venv/bin/devenv
  17. else
  18. DEVENV=devenv
  19. fi
  20. echo "${yellow}Automatically running devenv sync because SENTRY_POST_MERGE_AUTO_UPDATE is set.${reset}"
  21. if ! command -v "$DEVENV" >/dev/null 2>&1; then
  22. echo "devenv not found! install: https://github.com/getsentry/devenv#install"
  23. exit 1
  24. fi
  25. "$DEVENV" sync
  26. else
  27. 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}"
  28. fi
  29. fi