Created
August 15, 2014 19:08
-
-
Save kevinmichaelchen/3353eeeb1b6d4437ffe4 to your computer and use it in GitHub Desktop.
Outputs a Git command to rebase linear feature 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 python | |
# input: branches.txt lists feature branches | |
# branches MUST be on their own line | |
# branches MUST be ordered NEWEST to OLDEST | |
# output: the git command to rebase linear branches onto 'develop' | |
import sys | |
BRANCH = 'develop' | |
def main(branch=BRANCH, option='ours'): | |
f = open('branches.txt') | |
lines = f.read().splitlines() | |
f.close() | |
print lines | |
print '\n\n\n' | |
print 'Your command is:' | |
print '' | |
command = '' | |
stop = len(lines) - 1 | |
for i in range(0, stop): | |
new = lines[i] | |
old = lines[i+1] | |
sep = '' if i == stop - 1 else ' && ' | |
s = 'git rebase -s recursive -X ' + option + ' --onto ' + BRANCH + ' ' + old + ' ' + new + sep | |
command += s | |
print command | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment