GitRepository.set_upstream_branch: Catch errors to set upstream branch
authorGuido Günther <agx@sigxcpu.org>
Thu, 4 Jul 2013 15:00:02 +0000 (17:00 +0200)
committerGuido Günther <agx@sigxcpu.org>
Thu, 4 Jul 2013 15:51:59 +0000 (17:51 +0200)
gbp/git/repository.py

index e172aad68af80ff7c260a822309ee1e829370a73..03963670b8ed40a105396658237ffa3034f5910c 100644 (file)
@@ -538,8 +538,15 @@ class GitRepository(object):
             if not self.has_branch(branch, remote=remote):
                 raise GitRepositoryError("Branch %s doesn't exist!" % branch)
 
-        self._git_inout('branch', ["--set-upstream", local_branch, upstream],
-                        capture_stderr=True)
+        dummy, err, ret = self._git_inout('branch',
+                                          ['--set-upstream',
+                                           local_branch,
+                                           upstream],
+                                          capture_stderr=True)
+        if ret:
+            raise GitRepositoryError(
+                "Failed to set upstream branch '%s' for '%s': %s" %
+                (upstream, local_branch, err.strip()))
 
     def get_upstream_branch(self, local_branch):
         """