From 7d6b3072e15965ae61ce888c00427f8eacc3b7d5 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Tue, 8 Jul 2008 15:36:45 -0400 Subject: [PATCH] Implement push --- yap/yap.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/yap/yap.py b/yap/yap.py index 3c66b0e..f30450c 100644 --- a/yap/yap.py +++ b/yap/yap.py @@ -730,7 +730,37 @@ a previously added repository. os.system("git config remote.%s.fetch +refs/heads/*:refs/remotes/%s/*" % (name, url)) for remote, url in self._list_remotes(): - print "%s:\t\t%s" % (remote, url) + print "%-20s %s" % (remote, url) + + @takes_options("cd") + def cmd_push(self, repo, **flags): + "[-c | -d] " + + if repo not in self._list_remotes(): + raise YapError("No such repository: %s" % repo) + + current = get_output("git symbolic-ref HEAD")[0] + ref = current + current = current.replace('refs/heads/', '') + remote = get_output("git config branch.%s.remote" % current) + if remote and remote[0] == repo: + merge = get_output("git config branch.%s.merge" % current) + if merge: + ref = merge[0] + + if '-c' not in flags and '-d' not in flags: + if run_command("git rev-parse --verify refs/remotes/%s/%s" + % (remote, ref.replace('refs/heads/', ''))): + raise YapError("No matching branch on that repo. Use -c to create a new branch there.") + + if '-d' in flags: + lhs = "" + else: + lhs = "refs/heads/%s" % current + rc = os.system("git push %s %s:%s" % (repo, lhs, ref)) + if rc: + raise YapError("Push failed.") + def cmd_help(self, cmd=None): if cmd is not None: -- 2.11.4.GIT