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. 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. cat <<EOF
  16. [${red}${bold}!!!${reset}] ${red} It looks like some dependencies have changed that will require your intervention. Run the following to update:${reset}
  17. ${red}${bold}${update_command}${reset}
  18. EOF
  19. if [[ "$SENTRY_POST_MERGE_AUTO_UPDATE" ]]; then
  20. echo "${yellow}Automatically running update command because SENTRY_POST_MERGE_AUTO_UPDATE is set.${reset}"
  21. $update_command
  22. else
  23. 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}"
  24. fi
  25. fi