Created
April 11, 2017 18:10
-
-
Save major0/dddbb0e3023b09fce33fd1b0bbb3f692 to your computer and use it in GitHub Desktop.
Tool to aid back-porting a dev->topic_branch onto a release->integration branch.
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
#!/bin/sh | |
# Backport a topic-branch based on a development line back to a release branch. | |
# Generally this is a proof-of-concept/notes on overall process. Needs a number | |
# of sanity checks added before it is a real tool. | |
set -e | |
error() { echo "error: $*" >&2; } | |
die() { error "$*"; exit 1; } | |
## Update Branches | |
# FIXME we need to sanity check all the arguments | |
start="${1}" # What rev to reset the target to before merging | |
from="${2}" # Where to merge from | |
saved_cwd="${PWD}" | |
test -d "../${from}" || die "invalid worktree '${from}'" | |
set -- $(cd "../${from}" && git-branch-ancestry) | |
master="${1+master}" | |
# Use rebase to perform a type of cherry-pick which applies the string of | |
# revisions "onto" the target branch @ the start revision. | |
since="$(git merge-base --fork-point "${master}" "${from}")" | |
until="$(git rev-list --max-count=1 "${from}")" | |
git reset --hard "${start}" | |
onto="$(git symbolic-ref --short HEAD)" | |
git rebase --onto "${onto}" "${since}" "${until}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment