From 4e779d70b1e649c7491a81cca883964006836f73 Mon Sep 17 00:00:00 2001 From: yomguy Date: Mon, 16 Jul 2012 16:42:46 +0200 Subject: [PATCH] add repos management --- gitmanage.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 gitmanage.py diff --git a/gitmanage.py b/gitmanage.py new file mode 100644 index 0000000..40d6128 --- /dev/null +++ b/gitmanage.py @@ -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) + -- 2.39.5