summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Brandily <zzelle@gmail.com>2014-08-13 23:30:09 +0200
committerCedric Brandily <zzelle@gmail.com>2014-09-03 21:28:12 +0200
commit9f389bfec60766c5fd0642a43bbfbca78a7a997a (patch)
tree3b2c2ca096598492e5dbdc95dae02850e12b3077
parent499a2f3dbc49671ed2c35bb22c05682eba7878fe (diff)
downloadgit-review-9f389bfec60766c5fd0642a43bbfbca78a7a997a.tar.gz
Define -T/--no-topic to disable review submit with topic
The option -T/--no-topic disables review with topic (mutually exclusive with -t/--topic). It allows to submit: * a change without your current branch name as topic, * a change update without updating current topic. Change-Id: I06309b14246cb455d55c6833ab6adb932995edfa
-rw-r--r--README.rst4
-rw-r--r--git-review.14
-rwxr-xr-xgit_review/cmd.py16
-rw-r--r--git_review/tests/test_git_review.py19
4 files changed, 36 insertions, 7 deletions
diff --git a/README.rst b/README.rst
index f685ac8..3d2d3e0 100644
--- a/README.rst
+++ b/README.rst
@@ -41,6 +41,10 @@ If you want to supply a review topic::
git review -t topic/awesome-feature
+If you want to disable autogenerated topic::
+
+ git review -T
+
If you want to submit a branch for review and then remove the local branch::
git review -f
diff --git a/git-review.1 b/git-review.1
index a69324e..dd7bf34 100644
--- a/git-review.1
+++ b/git-review.1
@@ -38,7 +38,7 @@
.Fl s
.Op Ar branch
.Nm
-.Op Fl fnuvDR
+.Op Fl fnuvDRT
.Op Fl r Ar remote
.Op Fl t Ar topic
.Op Ar branch
@@ -138,6 +138,8 @@ Just run the repo setup commands but don\(aqt submit anything.
.It Fl t Ar topic , Fl \-topic= Ns Ar topic
Sets the target topic for this change on the gerrit server.
If not specified, a bug number from the commit summary will be used. Alternatively, the local branch name will be used if different from remote branch.
+.It Fl T , Fl \-no\-topic
+Submit review without topic.
.It Fl u , Fl \-update
Skip cached local copies and force updates from network resources.
.It Fl l , Fl \-list
diff --git a/git_review/cmd.py b/git_review/cmd.py
index d28f315..1e9fa27 100755
--- a/git_review/cmd.py
+++ b/git_review/cmd.py
@@ -1058,8 +1058,13 @@ def main():
parser = argparse.ArgumentParser(usage=usage, description=COPYRIGHT)
- parser.add_argument("-t", "--topic", dest="topic",
- help="Topic to submit branch to")
+ topic_arg_group = parser.add_mutually_exclusive_group()
+ topic_arg_group.add_argument("-t", "--topic", dest="topic",
+ help="Topic to submit branch to")
+ topic_arg_group.add_argument("-T", "--no-topic", dest="notopic",
+ action="store_true",
+ help="No topic except if explicitly provided")
+
parser.add_argument("-D", "--draft", dest="draft", action="store_true",
help="Submit review as a draft")
parser.add_argument("-c", "--compatible", dest="compatible",
@@ -1233,8 +1238,11 @@ def main():
ref = "for"
cmd = "git push %s HEAD:refs/%s/%s" % (remote, ref, branch)
- topic = options.topic or get_topic(branch)
- if topic != branch:
+ if options.topic is not None:
+ topic = options.topic
+ else:
+ topic = None if options.notopic else get_topic(branch)
+ if topic and topic != branch:
cmd += "/%s" % topic
if options.regenerate:
print("Amending the commit to regenerate the change id\n")
diff --git a/git_review/tests/test_git_review.py b/git_review/tests/test_git_review.py
index 6f538b6..9cdb6de 100644
--- a/git_review/tests/test_git_review.py
+++ b/git_review/tests/test_git_review.py
@@ -186,8 +186,9 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
self.assertIn('rebase', review_res)
self.assertEqual(self._run_git('rev-parse', 'HEAD^1'), head)
- def _assert_branch_would_be(self, branch):
- output = self._run_git_review('-n')
+ def _assert_branch_would_be(self, branch, extra_args=None):
+ extra_args = extra_args or []
+ output = self._run_git_review('-n', *extra_args)
# last non-empty line should be:
# git push gerrit HEAD:refs/publish/master
last_line = output.strip().split('\n')[-1]
@@ -210,6 +211,11 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
finally:
os.environ.update(LANG=lang_env)
+ def test_git_review_t(self):
+ self._run_git_review('-s')
+ self._simple_change('test file modified', 'commit message for bug 654')
+ self._assert_branch_would_be('master/zat', extra_args=['-t', 'zat'])
+
def test_bug_topic(self):
self._run_git_review('-s')
self._simple_change('a change', 'new change for bug 123')
@@ -230,6 +236,15 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
self._simple_change('a change', 'new change not for bluepring\nasdf')
self._assert_branch_would_be('master')
+ def test_git_review_T(self):
+ self._run_git_review('-s')
+ self._simple_change('test file modified', 'commit message for bug 456')
+ self._assert_branch_would_be('master/bug/456')
+ self._assert_branch_would_be('master', extra_args=['-T'])
+
+ def test_git_review_T_t(self):
+ self.assertRaises(Exception, self._run_git_review, '-T', '-t', 'taz')
+
def test_git_review_l(self):
self._run_git_review('-s')