]> git.parisson.com Git - telecaster-instance.git/commitdiff
add repos management
authoryomguy <yomguy@parisson.com>
Mon, 16 Jul 2012 14:42:46 +0000 (16:42 +0200)
committeryomguy <yomguy@parisson.com>
Mon, 16 Jul 2012 14:42:46 +0000 (16:42 +0200)
gitmanage.py [new file with mode: 0644]

diff --git a/gitmanage.py b/gitmanage.py
new file mode 100644 (file)
index 0000000..40d6128
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+
+import os, sys
+
+class GitManage(object):
+
+    def __init__(self):
+        self.exclude = ['']
+        self.dir = os.path.dirname(os.path.abspath(__file__))
+        self.apps = os.listdir(self.dir)
+
+    def process(self, args):
+        for app in self.apps:
+            if not app in self.exclude and os.path.isdir(self.dir + os.sep + app):
+                print app
+                os.chdir(self.dir + os.sep + app)
+                os.system('git ' + args)
+        os.chdir(self.dir)
+
+    def pull(self, repo, branch):
+        args = 'pull ' + repo + ' ' + branch
+        self.process(args)
+
+    def checkout(self, branch):
+        args = 'checkout ' + ' ' + branch
+        self.process(args)
+
+    def diff(self):
+        args = 'diff'
+        self.process(args)
+
+    def list_repos(self):
+        args = 'remote -v'
+        self.process(args)
+
+    def add_repo(self, name, repo):
+        for app in self.apps:
+            if not app in self.exclude and os.path.isdir(self.dir + os.sep + app):
+                print app
+                os.chdir(self.dir + os.sep + app)
+                args = 'remote add ' + name + ' ' + repo + app + '.git'
+                print args
+                os.system('git ' + args)
+
+    def delete_repo(self, repo):
+        for app in self.apps:
+            if not app in self.exclude and os.path.isdir(self.dir + os.sep + app):
+                print app
+                os.chdir(self.dir + os.sep + app)
+                args = 'remote rm ' + repo
+                print args
+                os.system('git ' + args)
+
+    def checkout(self, branch):
+        args = 'checkout ' + ' ' + branch
+        self.process(args)
+