Allow the default of notopic to be configurable

In our setup branch names are not designed to contain topics and are in
certain cases also dictated by other tools. To avoid having git-review
constantly overwrite the topics it is useful to set --no-topic to be the
default state when running git-review.

Change-Id: I1e77e062d73d47f1cceeb34b3418c074d06c9005
This commit is contained in:
Mattias Jernberg 2019-10-04 12:10:50 +02:00 committed by Sorin Sbârnea
parent 4af1703a90
commit 96cfd92c89
4 changed files with 19 additions and 2 deletions

View File

@ -228,6 +228,8 @@ This setting determines the default name of gerrit git repo
This setting determines the default name to use for gerrit remote
.It gitreview.branch
This setting determines the default branch
.It gitreview.notopic
Set to true to never submit with a default topic
.It gitreview.track
Determines whether to prefer the currently-tracked branch (if any)
and the branch against which the changeset was submitted to Gerrit

View File

@ -43,7 +43,7 @@ GLOBAL_CONFIG = "/etc/git-review/git-review.conf"
USER_CONFIG = os.path.join(CONFIGDIR, "git-review.conf")
DEFAULTS = dict(scheme='ssh', hostname=False, port=None, project=False,
branch='master', remote="gerrit", rebase="1",
track="0", usepushurl="0")
track="0", usepushurl="0", notopic=False)
COPYRIGHT = """\
Copyright (C) 2011-2020 OpenStack LLC.
@ -730,6 +730,7 @@ def load_config_file(config_file):
'remote': 'defaultremote',
'rebase': 'defaultrebase',
'track': 'track',
'notopic': 'notopic',
'usepushurl': 'usepushurl',
}
config = {}
@ -1575,6 +1576,7 @@ review.
parser.set_defaults(rebase=convert_bool(config['rebase']),
track=convert_bool(config['track']),
remote=None,
notopic=convert_bool(config['notopic']),
usepushurl=convert_bool(config['usepushurl']))
options = parser.parse_args()

View File

@ -403,6 +403,11 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
self._assert_branch_would_be('master%topic=zat',
extra_args=['-t', 'zat'])
# -t takes precedence over notopic
self._run_git('config', 'gitreview.notopic', 'true')
self._assert_branch_would_be('master%topic=zat',
extra_args=['-t', 'zat'])
def test_git_review_T(self):
self._run_git_review('-s')
self._run_git('checkout', '-b', 'bug/456')
@ -410,6 +415,14 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
self._assert_branch_would_be('master%topic=bug/456')
self._assert_branch_would_be('master', extra_args=['-T'])
self._run_git('config', 'gitreview.notopic', 'true')
self._assert_branch_would_be('master')
self._run_git('config', 'gitreview.notopic', 'false')
self._assert_branch_would_be('master%topic=bug/456')
# -T takes precedence over notopic=false
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')

View File

@ -1,5 +1,5 @@
hacking>=2.0.0,<2.1.0
mock
fixtures>=0.3.14
stestr>=2.2.0
stestr>=2.2.0,<3.0.0
testtools>=0.9.34