Allow choosing field for author in named branch
This adds a setting for choosing which of {name, email, username} to use as "author" when constructing the name for the branch to where a change is downloaded. The rationale is that sometimes the given "name" is just long and unwieldy (when displaying the branch in the shell prompt, for example), and one may be already used to the "username". Change-Id: Ieed465f69ed0c0864979a92f609bd8f58cd8e883
This commit is contained in:
parent
23980a8b9d
commit
a0963a1b51
@ -292,6 +292,12 @@ This setting takes precedence over repository\-specific configuration
|
|||||||
in the
|
in the
|
||||||
.Pa .gitreview
|
.Pa .gitreview
|
||||||
file.
|
file.
|
||||||
|
.It gitreview.branchauthor
|
||||||
|
This setting changes the look of the author part when naming the local
|
||||||
|
branch of a downloaded change. Value must be one of "name", "email",
|
||||||
|
or "username". Default is "name". See also the
|
||||||
|
.Fl \-download
|
||||||
|
option.
|
||||||
.El
|
.El
|
||||||
.Bl -tag
|
.Bl -tag
|
||||||
.It color.review
|
.It color.review
|
||||||
|
@ -43,7 +43,7 @@ GLOBAL_CONFIG = "/etc/git-review/git-review.conf"
|
|||||||
USER_CONFIG = os.path.join(CONFIGDIR, "git-review.conf")
|
USER_CONFIG = os.path.join(CONFIGDIR, "git-review.conf")
|
||||||
DEFAULTS = dict(scheme='ssh', hostname=False, port=None, project=False,
|
DEFAULTS = dict(scheme='ssh', hostname=False, port=None, project=False,
|
||||||
branch='master', remote="gerrit", rebase="1",
|
branch='master', remote="gerrit", rebase="1",
|
||||||
track="0", usepushurl="0", notopic=False)
|
track="0", usepushurl="0", notopic=False, branchauthor="name")
|
||||||
COPYRIGHT = """\
|
COPYRIGHT = """\
|
||||||
Copyright (C) 2011-2020 OpenStack LLC.
|
Copyright (C) 2011-2020 OpenStack LLC.
|
||||||
|
|
||||||
@ -69,6 +69,7 @@ _use_color = None
|
|||||||
_orig_head = None
|
_orig_head = None
|
||||||
_rewrites = None
|
_rewrites = None
|
||||||
_rewrites_push = None
|
_rewrites_push = None
|
||||||
|
BRANCHAUTHOR = None
|
||||||
|
|
||||||
|
|
||||||
class colors(object):
|
class colors(object):
|
||||||
@ -732,6 +733,7 @@ def load_config_file(config_file):
|
|||||||
'track': 'track',
|
'track': 'track',
|
||||||
'notopic': 'notopic',
|
'notopic': 'notopic',
|
||||||
'usepushurl': 'usepushurl',
|
'usepushurl': 'usepushurl',
|
||||||
|
'branchauthor': 'branchauthor',
|
||||||
}
|
}
|
||||||
config = {}
|
config = {}
|
||||||
for config_key, option_name in options.items():
|
for config_key, option_name in options.items():
|
||||||
@ -1200,7 +1202,8 @@ def fetch_review(review, masterbranch, remote, project):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
topic = review
|
topic = review
|
||||||
try:
|
try:
|
||||||
author = re.sub(r'\W+', '_', review_info['owner']['name']).lower()
|
author = re.sub(r'\W+', '_',
|
||||||
|
review_info['owner'][BRANCHAUTHOR]).lower()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
author = 'unknown'
|
author = 'unknown'
|
||||||
remote_branch = review_info['branch']
|
remote_branch = review_info['branch']
|
||||||
@ -1413,7 +1416,19 @@ git-review is a tool that helps submitting git branches to gerrit for
|
|||||||
review.
|
review.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(usage=usage, description=description)
|
epilog = """\
|
||||||
|
additional information:
|
||||||
|
|
||||||
|
Options configurable using: git config --global gitreview.OPTION VALUE
|
||||||
|
|
||||||
|
branchauthor name (default), username, email
|
||||||
|
"""
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
usage=usage,
|
||||||
|
description=description,
|
||||||
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
|
epilog=epilog)
|
||||||
|
|
||||||
topic_arg_group = parser.add_mutually_exclusive_group()
|
topic_arg_group = parser.add_mutually_exclusive_group()
|
||||||
topic_arg_group.add_argument("-t", "--topic", dest="topic",
|
topic_arg_group.add_argument("-t", "--topic", dest="topic",
|
||||||
@ -1607,6 +1622,13 @@ review.
|
|||||||
yes = options.yes
|
yes = options.yes
|
||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
|
global BRANCHAUTHOR
|
||||||
|
BRANCHAUTHOR = config['branchauthor']
|
||||||
|
if BRANCHAUTHOR not in ["name", "email", "username"]:
|
||||||
|
warn("Invalid gitreview.branchauthor: %s (using default: %s)"
|
||||||
|
% (BRANCHAUTHOR, DEFAULTS["branchauthor"]))
|
||||||
|
BRANCHAUTHOR = DEFAULTS["branchauthor"]
|
||||||
|
|
||||||
if options.track:
|
if options.track:
|
||||||
remote, branch = resolve_tracking(remote, branch)
|
remote, branch = resolve_tracking(remote, branch)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user