export: determine remote repo name from git config
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 9 Dec 2013 14:19:54 +0000 (16:19 +0200)
committerQiang Z Zhang <qiang.z.zhang@intel.com>
Mon, 23 Dec 2013 08:19:24 +0000 (10:19 +0200)
Instead of trying to guess it from the remote tracking branch name which
can be ambigous.

Change-Id: I029c3fadb6f9ea63fa1c280e7183deba56c0e7ff
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gitbuildsys/cmd_export.py

index e991a95ad76bcd5435e44628d2457cf0e6f2383d..ef8725d02bdadd81f8c747c60c43b1928d6ed7c7 100644 (file)
@@ -120,11 +120,16 @@ def create_gbp_export_args(repo, commit, export_dir, tmp_dir, spec, args,
         remotename = 'origin' if 'origin' in remotes else remotes.keys()[0]
         # Take the remote repo of current branch, if available
         try:
-            remote_branch = repo.get_upstream_branch(repo.branch)
-            if remote_branch:
-                remotename = remote_branch.split("/")[0]
-        except GitRepositoryError:
+            config_remote = repo.get_config('branch.%s.remote' % repo.branch)
+        except KeyError:
             pass
+        else:
+            if config_remote in remotes:
+                remotename = config_remote
+            elif config_remote != '.':
+                log.warning("You appear to have non-existent remote '%s' "
+                            "configured for branch '%s'. Check your git config!"
+                            % (config_remote, repo.branch))
         reponame = urlparse(remotes[remotename][0]).path.lstrip('/')
 
     packaging_dir = get_packaging_dir(args)