post-merge 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. grep_pattern="requirements-dev-frozen.txt|migrations"
  11. if [[ "$SENTRY_DEVENV_SKIP_FRONTEND" != "1" ]]; then
  12. grep_pattern+="|yarn.lock"
  13. fi
  14. if grep -E --quiet "$grep_pattern" "$files_changed_upstream"; then
  15. cat <<EOF
  16. [${red}${bold}!!!${reset}] ${red} It looks like some dependencies have changed. Run devenv sync to resync your environment.${reset}
  17. EOF
  18. if [[ "$SENTRY_POST_MERGE_AUTO_UPDATE" ]]; then
  19. if [ -f .venv/bin/devenv ]; then
  20. DEVENV=.venv/bin/devenv
  21. else
  22. DEVENV=devenv
  23. fi
  24. echo "${yellow}Automatically running devenv sync because SENTRY_POST_MERGE_AUTO_UPDATE is set.${reset}"
  25. if ! command -v "$DEVENV" >/dev/null 2>&1; then
  26. echo "devenv not found! install: https://github.com/getsentry/devenv#install"
  27. exit 1
  28. fi
  29. "$DEVENV" sync
  30. else
  31. 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}"
  32. fi
  33. fi