From: Barış Metin Date: Tue, 27 Jul 2010 09:55:13 +0000 (+0200) Subject: keep track of remote branches locally to be able to push w/o errors X-Git-Tag: 5.0-rc15~55 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=7d9ed6517fc0c390bf5f6640356c3fb5175be33e;hp=fc3895027d5e5d0ee222f46ebc3138f40bb12546;p=build.git keep track of remote branches locally to be able to push w/o errors --- diff --git a/module-tools.py b/module-tools.py index 940e4b5b..4a4a8793 100755 --- a/module-tools.py +++ b/module-tools.py @@ -309,7 +309,9 @@ class GitRepository: def to_branch(self, branch, remote=True): if remote: - branch = "origin/%s" % branch + command = "git branch --track %s origin/%s" % (branch, branch) + c = Command(command, self.options) + self.__run_in_repo(c.output_of, with_stderr=True) return self.__run_command_in_repo("git checkout %s" % branch) def to_tag(self, tag): @@ -327,11 +329,14 @@ class GitRepository: c = Command("git diff %s" % tagname, self.options) return self.__run_in_repo(c.output_of, with_stderr=True) - def commit(self, logfile): + def commit(self, logfile, branch="master"): self.__run_command_in_repo("git add .", ignore_errors=True) self.__run_command_in_repo("git add -u", ignore_errors=True) self.__run_command_in_repo("git commit -F %s" % logfile, ignore_errors=True) - self.__run_command_in_repo("git push") + if branch == "master": + self.__run_command_in_repo("git push") + else: + self.__run_command_in_repo("git push %s:%s" % (branch, branch)) self.__run_command_in_repo("git push --tags") def revert(self, f=""): @@ -997,7 +1002,10 @@ n: move to next file"""%locals() print self.repository.diff() def commit_all_changes(log): - self.repository.commit(log) + if hasattr(self,'branch'): + self.repository.commit(log, branch=self.branch) + else: + self.repository.commit(log) build.commit(log) self.run_prompt("Review module and build", diff_all_changes)