diff options
author | David Robillard <d@drobilla.net> | 2016-01-07 09:49:38 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-01-07 09:49:38 -0500 |
commit | dc2029153e2ce2bd4c0e5b2c91dc2f8ec98e6e37 (patch) | |
tree | 4fd040847c103aa11cc15a9d7ddc653fe0b91a16 | |
parent | 4cce2a30ac592c0fb9abf95d16ef6b9d74b1ca20 (diff) | |
download | drobillad-dc2029153e2ce2bd4c0e5b2c91dc2f8ec98e6e37.tar.gz drobillad-dc2029153e2ce2bd4c0e5b2c91dc2f8ec98e6e37.tar.bz2 drobillad-dc2029153e2ce2bd4c0e5b2c91dc2f8ec98e6e37.zip |
Add waf rebase command
Patch from Robin Gareus, with minor clean-ups.
-rw-r--r-- | wscript | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -1,5 +1,6 @@ #!/usr/bin/env python import os +import time import subprocess import waflib.Logs as Logs import waflib.Options as Options @@ -36,6 +37,42 @@ projects = ''' # plugins/dirg.lv2 # plugins/lolep.lv2 +def rebase(ctx): + 'rebase all git submodules' + + def run(cmd): + 'run a command and return all output as a list of lines' + proc = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) + return proc.communicate()[0].splitlines() + + for i in projects: + Logs.info('Updating %s' % i) + old_cwd = os.getcwd() + try: + os.chdir(i) + if os.system('git diff-files --quiet --'): + raise Exception + if os.system('git diff-index --cached --quiet HEAD --'): + raise Exception + output = run('git rev-parse --abbrev-ref HEAD') + branch = output[0].decode('utf-8') + if branch != "master": + os.system('git checkout master') + output = run('git log -n 1 --pretty="%H"') + curhead = output[0].decode('utf-8') + os.system('git pull --rebase') + newhead = output[0].decode('utf-8') + output = run('git log -n 1 --pretty="%H"') + if branch != "master": + os.system('git checkout ' + branch) + if curhead != newhead: + os.system('git branch bak-'+ str(time.time())) + os.system('git rebase master') + except Exception: + print "Repository is not clean, skipped" + finally: + os.chdir(old_cwd) + def update(ctx): 'updates all git submodules' os.system('git submodule update') |