GitRepository: Allow to delete remote branches
authorGuido Günther <agx@sigxcpu.org>
Tue, 25 Oct 2011 10:42:15 +0000 (12:42 +0200)
committerGuido Günther <agx@sigxcpu.org>
Wed, 26 Oct 2011 08:00:54 +0000 (10:00 +0200)
gbp/git.py

index f52b09b..8c0debf 100644 (file)
@@ -388,14 +388,20 @@ class GitRepository(object):
 
         self._git_command("branch", args)
 
-    def delete_branch(self, branch):
+    def delete_branch(self, branch, remote=False):
         """
         Delete branch 'branch'
 
         @param branch: name of the branch to delete
+        @type branch: string
+        @param remote: delete a remote branch
+        @param remote: bool
         """
+        args = [ "-D" ]
+        args += [ "-r" ] if remote else []
+
         if self.get_branch() != branch:
-            self._git_command("branch", ["-D", branch])
+            self._git_command("branch", args + [branch])
         else:
             raise GitRepositoryError, "Can't delete the branch you're on"