post-merge 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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. update_command="make ${pc}${py}${js}${migrations}"
  14. [[ "$needs_update" ]] && cat <<EOF
  15. [${red}${bold}!!!${reset}] ${red} It looks like some dependencies have changed that will require your intervention. Run the following to update:${reset}
  16. ${red}${bold}${update_command}${reset}
  17. ${yellow}If you want these commands to automatically be executed after pulling code you can export the SENTRY_POST_MERGE_AUTO_UPDATE variable.${reset}
  18. EOF
  19. if [[ "$SENTRY_POST_MERGE_AUTO_UPDATE" && "$needs_update" ]]; then
  20. $update_command
  21. fi