Last active
December 6, 2018 09:49
-
-
Save morozov/b2d8d8e5c0660872c0b835f7586eec47 to your computer and use it in GitHub Desktop.
A shell script for back-porting Doctrine DBAL pull requests from master to older branches
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 | |
set -eu | |
if [ $# -ne 2 ]; then | |
echo "Usage: `basename $0` <pull> <branch>"; | |
exit 1; | |
fi | |
PULL="$1" | |
TARGET_BRANCH="$2" | |
TOPIC_BRANCH="bpo/$TARGET_BRANCH/#$PULL" | |
git fetch -f upstream "pull/$PULL/head:$TOPIC_BRANCH" | |
git checkout "$TOPIC_BRANCH" | |
# https://stackoverflow.com/a/30563070/146187 | |
MERGE_BASE=$(diff -u \ | |
<(git rev-list --first-parent upstream/master) \ | |
<(git rev-list --first-parent HEAD) \ | |
| sed -ne "s/^ //p" \ | |
| head -1 | |
) | |
git rebase "$MERGE_BASE" --onto "$TARGET_BRANCH" | |
git checkout "$TARGET_BRANCH" | |
git merge "$TOPIC_BRANCH" --no-ff --no-edit | |
git branch -D "$TOPIC_BRANCH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The remote pointing to the https://github.com/doctrine/dbal repository is expected to be named
upstream
.Example usage:
./backport.sh 3385 2.9
.