Make the default branch configurable
This adds the defaultbranch= option to the config file format, and makes it the default for the BRANCH command line parameter. Also removes duplication of the dict with default values (Amended to pass pep8) Change-Id: I0fae7ca3a7662fccd491f84a7a3a009480b1c39c
This commit is contained in:
@@ -57,10 +57,11 @@ Example .gitreview file (used to upload for git-review itself)
|
|||||||
host=review.openstack.org
|
host=review.openstack.org
|
||||||
port=29418
|
port=29418
|
||||||
project=openstack-ci/git-review.git
|
project=openstack-ci/git-review.git
|
||||||
|
defaultbranch=master
|
||||||
|
|
||||||
Required values: host, project
|
Required values: host, project
|
||||||
|
|
||||||
Optional values: port
|
Optional values: port (default: 29418), defaultbranch (default: master)
|
||||||
|
|
||||||
### Notes
|
### Notes
|
||||||
* Username not required because it is requested on first run
|
* Username not required because it is requested on first run
|
||||||
|
10
git-review
10
git-review
@@ -279,17 +279,19 @@ def check_color_support():
|
|||||||
|
|
||||||
def get_config():
|
def get_config():
|
||||||
"""Get the configuration options set in the .gitremote file, if present."""
|
"""Get the configuration options set in the .gitremote file, if present."""
|
||||||
"""Returns a hashmap with hostname, port and project."""
|
"""Returns a hashmap with hostname, port, project and defaultbranch."""
|
||||||
"""If there is no .gitremote file, default values will be used."""
|
"""If there is no .gitremote file, default values will be used."""
|
||||||
config = dict(hostname=False, port='29418', project=False)
|
config = dict(hostname=False, port='29418', project=False,
|
||||||
|
defaultbranch='master')
|
||||||
top_dir = run_command('git rev-parse --show-toplevel')
|
top_dir = run_command('git rev-parse --show-toplevel')
|
||||||
target_file = os.path.join(top_dir, ".gitreview")
|
target_file = os.path.join(top_dir, ".gitreview")
|
||||||
if os.path.exists(target_file):
|
if os.path.exists(target_file):
|
||||||
configParser = ConfigParser.ConfigParser(dict(port='29418'))
|
configParser = ConfigParser.ConfigParser(config)
|
||||||
configParser.read(target_file)
|
configParser.read(target_file)
|
||||||
config['hostname'] = configParser.get("gerrit", "host")
|
config['hostname'] = configParser.get("gerrit", "host")
|
||||||
config['port'] = configParser.get("gerrit", "port")
|
config['port'] = configParser.get("gerrit", "port")
|
||||||
config['project'] = configParser.get("gerrit", "project")
|
config['project'] = configParser.get("gerrit", "project")
|
||||||
|
config['defaultbranch'] = configParser.get("gerrit", "defaultbranch")
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
@@ -581,7 +583,7 @@ def main():
|
|||||||
parser.add_argument("--version", action="version",
|
parser.add_argument("--version", action="version",
|
||||||
version='%s version %s' % \
|
version='%s version %s' % \
|
||||||
(os.path.split(sys.argv[0])[-1], version))
|
(os.path.split(sys.argv[0])[-1], version))
|
||||||
parser.add_argument("branch", nargs="?", default="master")
|
parser.add_argument("branch", nargs="?", default=config['defaultbranch'])
|
||||||
parser.set_defaults(dry=False, rebase=True, verbose=False, update=False,
|
parser.set_defaults(dry=False, rebase=True, verbose=False, update=False,
|
||||||
setup=False, yes=False, remote="gerrit")
|
setup=False, yes=False, remote="gerrit")
|
||||||
|
|
||||||
|
@@ -101,6 +101,7 @@ information about your gerrit installation in it. The format is:
|
|||||||
host=review.example.com
|
host=review.example.com
|
||||||
port=29418
|
port=29418
|
||||||
project=project.git
|
project=project.git
|
||||||
|
defaultbranch=master
|
||||||
.ft P
|
.ft P
|
||||||
.fi
|
.fi
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
|
Reference in New Issue
Block a user