post-merge 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. trap "rm -f ${files_changed_upstream}" EXIT
  8. git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD >"$files_changed_upstream"
  9. grep --quiet 'requirements-dev-frozen.txt' "$files_changed_upstream" && py="install-py-dev "
  10. grep --quiet 'yarn.lock' "$files_changed_upstream" && js="install-js-dev "
  11. grep --quiet 'migrations' "$files_changed_upstream" && migrations="apply-migrations "
  12. [[ "$pc" || "$py" || "$js" || "$migrations" ]] && needs_update=1
  13. if [[ "$needs_update" ]]; then
  14. update_command="make ${pc}${py}${js}${migrations}"
  15. if [ ! -x "${HOME}/.local/share/sentry-devenv/bin/devenv" ]; then
  16. # Old and busted.
  17. if [ ! -f ".venv/bin/activate" ]; then
  18. prompt_python_venv_creation
  19. # This is time consuming but it has to be done
  20. source "${SENTRY_ROOT}/scripts/bootstrap-py3-venv"
  21. fi
  22. else
  23. # The new hotness (coming soon).
  24. update_command="devenv sync"
  25. fi
  26. cat <<EOF
  27. [${red}${bold}!!!${reset}] ${red} It looks like some dependencies have changed that will require your intervention. Run the following to update:${reset}
  28. ${red}${bold}${update_command}${reset}
  29. EOF
  30. if [[ "$SENTRY_POST_MERGE_AUTO_UPDATE" ]]; then
  31. echo "${yellow}Automatically running update command because SENTRY_POST_MERGE_AUTO_UPDATE is set.${reset}"
  32. $update_command
  33. else
  34. echo "${yellow}If you want these commands to be executed automatically after pulling code, you can export the SENTRY_POST_MERGE_AUTO_UPDATE variable.${reset}"
  35. fi
  36. fi