Last active
September 1, 2021 21:22
-
-
Save rogeruiz/8597a219f0a4680efba63327d343e4ad to your computer and use it in GitHub Desktop.
Testing a post-merge hook the hard way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
patch_file=$( | |
curl -L \ | |
-s \ | |
https://github.com/transcom/mymove/commit/e22ed5cdd10d7fb46e448c4d99b9d98880279a5a.patch | |
) | |
# Checkout a previous branch that doesn't have migration/ changes in it. | |
git reset --hard 6544b43723fd0e45e9f24046b1f4d98017163e11 | |
# Apply the patch file from above to your local branch to get the script. | |
echo "${patch_file}" | git apply | |
# Because we can't go forward in time due to changes in the previous patch, | |
# we'll need to turn this from a `pre-commit` script to an actual Git hook | |
# named `post-merge`. The `pre-commit` tooling says it will run based on actual | |
# Git hooks so it's expected for it to work even though we're not testing | |
# through the actual `pre-commit` "stages". | |
mv scripts/check-changes .git/hooks/post-merge | |
git checkout -- scripts/ .pre-commit-config.yaml | |
# Pull the latest changes to get to the tip of HEAD and there should be line | |
# printed at the end that mentions that there have been changes to | |
# `migrations/`. | |
git pull --ff-only && rm .git/hooks/post/merge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment