Slightly modify the "publish" command description
[stgit] / stgit / commands / publish.py
index 0358a09..391a6a2 100644 (file)
@@ -21,8 +21,9 @@ from stgit.commands import common
 from stgit.config import config
 from stgit.lib import git, stack
 from stgit.out import out
+from stgit import utils
 
-help = 'Publish the stack changes to a merge-friendly head'
+help = 'Push the stack changes to a merge-friendly branch'
 kind = 'stack'
 usage = ['[options] [branch]']
 description = """
@@ -72,7 +73,7 @@ def __create_commit(repository, tree, parents, options, message = ''):
     cd = git.CommitData(
         tree = tree, parents = parents, message = message,
         author = git.Person.author(), committer = git.Person.committer())
-    cd = common.update_commit_data(cd, options, allow_edit = True)
+    cd = common.update_commit_data(cd, options)
 
     return repository.commit(cd)
 
@@ -88,6 +89,9 @@ def func(parser, options, args):
     else:
         parser.error('incorrect number of arguments')
 
+    if not public_ref.startswith('refs/heads/'):
+        public_ref = 'refs/heads/' + public_ref
+
     # just clone the stack if the public ref does not exist
     if not repository.refs.exists(public_ref):
         repository.refs.set(public_ref, stack.head, 'publish')
@@ -105,9 +109,15 @@ def func(parser, options, args):
     # check for rebased stack. In this case we emulate a merge with the stack
     # base by setting two parents.
     merge_bases = repository.get_merge_bases(public_head, stack.base)
+    if public_head in merge_bases:
+        # fast-forward the public ref
+        repository.refs.set(public_ref, stack.head, 'publish')
+        out.info('Fast-forwarded "%s"' % public_ref)
+        return
     if not stack.base in merge_bases:
-        message = 'Merge %s into %s' % (repository.describe(stack.base),
-                                        public_ref)
+        message = 'Merge %s into %s' % (repository.describe(stack.base).strip(),
+                                        utils.strip_prefix('refs/heads/',
+                                                           public_ref))
         public_head = __create_commit(repository, stack.head.data.tree,
                                       [public_head, stack.base], options,
                                       message)
@@ -128,7 +138,7 @@ def func(parser, options, args):
             cd = pc.data.set_parent(public_head)
             public_head = repository.commit(cd)
             public_tree = public_head.data.tree
-            out.start('Published new patch "%s"' % p)
+            out.info('Published new patch "%s"' % p)
 
     # create a new commit (only happens if no new patches are detected)
     if public_tree.sha1 != stack.head.data.tree.sha1: