GitRepository.set_upstream_branch: use --set-upstream-to if available
authorGuido Günther <agx@sigxcpu.org>
Thu, 4 Jul 2013 15:18:29 +0000 (17:18 +0200)
committerGuido Günther <agx@sigxcpu.org>
Thu, 4 Jul 2013 15:51:59 +0000 (17:51 +0200)
since --set-upstream is deprecated.

gbp/git/repository.py

index 0396367..502a391 100644 (file)
@@ -538,10 +538,13 @@ class GitRepository(object):
             if not self.has_branch(branch, remote=remote):
                 raise GitRepositoryError("Branch %s doesn't exist!" % branch)
 
+        if self._cmd_has_feature('branch', 'set-upstream-to'):
+            args = ['--set-upstream-to=%s' % upstream, local_branch]
+        else:
+            args = ["--set-upstream", local_branch, upstream]
+
         dummy, err, ret = self._git_inout('branch',
-                                          ['--set-upstream',
-                                           local_branch,
-                                           upstream],
+                                          args,
                                           capture_stderr=True)
         if ret:
             raise GitRepositoryError(