Created
September 4, 2024 00:17
-
-
Save kdave/2c08c9202870ff90ce9e4610d59fd7c7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh -x | |
# | |
remote=$(git rev-parse remotes/gh-b/for-next) | |
expect="${1:-$remote}" | |
echo "git diff remotes/gh-b/for-next" | |
echo "expecting: $expect" | |
if ! git push gh-b b-for-next:for-next; then | |
# Try leased push if possible | |
if ! [ -z "$expect" ]; then | |
echo "Leased push with $expect" | |
if git push --force-with-lease=for-next:"$expect" gh-b b-for-next:for-next; then | |
echo "OK" | |
exit | |
else | |
echo "Lease did not work, you have to decide" | |
fi | |
fi | |
echo "Force push? [y/N]" | |
read -n 1 answer | |
if [ "$answer" = 'y' ]; then | |
git push -f gh-b b-for-next:for-next | |
else | |
echo "Ok, not pushed" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment