summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wscript37
1 files changed, 37 insertions, 0 deletions
diff --git a/wscript b/wscript
index 04a19b5..e46be34 100644
--- a/wscript
+++ b/wscript
@@ -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')