submit: try to guess the remote server
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 16 Oct 2012 08:01:07 +0000 (11:01 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Wed, 17 Oct 2012 05:11:26 +0000 (08:11 +0300)
If the current branch has upstream set, use it's remote as the server to
push to. Only uses 'origin' as default if no upstream is set.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gitbuildsys/cmd_submit.py
tools/gbs

index 244707026abbc4042e58582fe3c81b121e320592..baaa6aa8123f0b98a5f734dbcd3dea55d5cb2637 100644 (file)
@@ -44,18 +44,25 @@ def main(args):
     except GitRepositoryError, err:
         msger.error(str(err))
 
+    try:
+        upstream = repo.get_upstream_branch(target_branch)
+    except GitRepositoryError:
+        pass
+    if not args.remote:
+        if upstream:
+            args.remote = upstream.split('/')[0]
+        else:
+            msger.info("no upstream set for the current branch, using "
+                       "'origin' as the remote server")
+            args.remote = 'origin'
     if not args.target:
-        try:
-            upstream = repo.get_upstream_branch(target_branch)
-            if upstream and upstream.startswith(args.remote):
-                target_branch = os.path.basename(upstream)
-            else:
-                msger.warning('can\'t find upstream branch for current branch '\
-                              '%s. Gbs will try to find it by name. Please '\
-                              'consider to use git-branch --set-upstream to '\
-                              'set upstream remote branch.' % target_branch)
-        except GitRepositoryError:
-            pass
+        if upstream and upstream.startswith(args.remote):
+            target_branch = os.path.basename(upstream)
+        else:
+            msger.warning('can\'t find upstream branch for current branch '\
+                          '%s. Gbs will try to find it by name. Please '\
+                          'consider to use git-branch --set-upstream to '\
+                          'set upstream remote branch.' % target_branch)
 
     try:
         if target_branch == 'master':
@@ -69,7 +76,7 @@ def main(args):
         msger.error('failed to create tag %s: %s ' % (tagname, str(err)))
 
     try:
-        msger.info('pushing tag to remote server')
+        msger.info("pushing tag to remote '%s'" % args.remote)
         repo.push_tag(args.remote, tagname)
     except GitRepositoryError, err:
         repo.delete_tag(tagname)
index b8176904bcd8219116eeda5abf367d059fef2e5d..a79670a998886a83a1b05a6213ab9ed3e4df93fa 100755 (executable)
--- a/tools/gbs
+++ b/tools/gbs
@@ -301,9 +301,9 @@ def submit_parser(parser):
                         help='using the given key to make a GPG-signed tag')
     parser.add_argument('-t', '--target',
                         help='specify target version to submit, eg: trunk.')
-    parser.add_argument('-r', '--remote', default='origin',
-                        help='specify gerrit project server, default value is '
-                        'origin for example:\nssh://user@review.tizen.org:29418'
+    parser.add_argument('-r', '--remote',
+                        help='specify gerrit project server, '
+                        'for example:\nssh://user@review.tizen.org:29418'
                         '/public/base/gcc')
 
     parser.set_defaults(alias="sr")