diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2008-11-22 14:00:45 -0500 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2008-11-22 14:00:45 -0500 |
commit | cc442c4f0e10cf503918319a005855f3f06a1bf0 (patch) | |
tree | 226efdd09964ca4b2b8b653c21ba28a3da7b6227 | |
parent | 8836bbcb6c8d10fabc10dda1dc52a116ae652b13 (diff) | |
download | git-bz-cc442c4f0e10cf503918319a005855f3f06a1bf0.tar.gz |
Allowing configuring a default product and component
Allowing specifying bz-tracker.<tracker>.default-product and
bz-tracker.<tracker>.default-component. This is useful when done
in the per-repository config.
Add a "Per-repository configuration" section in the docs with examples.
-rw-r--r-- | TODO | 6 | ||||
-rwxr-xr-x | git-bz | 63 |
2 files changed, 50 insertions, 19 deletions
@@ -37,12 +37,6 @@ Allow editing comment used for attachments That you could uncomment to obsolete old patches. -Allow specifying a default product/component for 'git bz file' - - Specifying the product/component in the global git config would - be a bit silly/dangerous, but doing it locally in the git config - for a single repo would be quit useful. - Use XML-RPC when available. Maybe use python-bugzilla: http://fedorahosted.org/python-bugzilla/ @@ -77,12 +77,13 @@ # # to include the bug URL. (See 'git bz add-url') # git bz attach -u bugzilla.gnome.org:1234 b50ea9bd -1 # -# git bz file [-<N>] [options] <product>/<component> [<since> | <revision range>] +# git bz file [-<N>] [options] [[<product>]/<component>] [<since> | <revision range>] # # Like 'attach', but files a new bug. Opens an editor for the user to # enter the summary and description for the bug. If only a single commit # is named summary defaults to the subject of the commit, and the description -# to the body of the bug +# to the body of the bug. The product and component must be specified unless +# you have configured defaults. # # Examples: # @@ -122,6 +123,19 @@ # # git config --global bz.default-tracker bgo # +# Per-repository configuration +# ============================ +# Setting the default tracker, product and component in the local +# config for a repository can be useful: +# +# git config bz.default-tracker bugzilla.gnome.org +# git config bz-tracker.bugzilla.gnome.org.default-product gnome-shell +# git config bz-tracker.bugzilla.gnome.org.default-component general +# +# (The default-product and default-component values must always be +# specified within the config for a particular tracker.) Note the +# absence of the --global options. +# # Per Tracker Configuration # ========================= # git-bz needs some configuration specific to the bugzilla instance (tracker), @@ -853,12 +867,34 @@ def do_attach(bug_reference, since_or_revision_range): attach_commits(bug, commits) -def do_file(product_component, since_or_revision_range): - m = re.match("([^/]+)/([^/]+)", product_component) - if not m: - die("'%s' is not a valid <product>/<component> pair" % product_component) - product = m.group(1) - component = m.group(2) +def do_file(*args): + if len(args) == 1: + product_component, since_or_revision_range = None, args[0] + else: + product_component, since_or_revision_range = args[0], args[1] + + config = get_config(get_tracker()) + + if product_component: + m = re.match("(?:([^/]+)/)?([^/]+)", product_component) + if not m: + die("'%s' is not a valid [<product>/]<component>" % product_component) + + product = m.group(1) + component = m.group(2) + + if not product: + if not 'default-product' in config: + die("'%s' does not specify a product and no default product is configured" % product_component) + product = config['default-product'] + else: + if not 'default-product' in config: + die("[<product>/]<component> not specified and no default product is configured") + if not 'default-component' in config: + die("[<product>/]<component> not specified and no default component is configured") + + product = config['default-product'] + component = config['default-component'] commits = get_commits(since_or_revision_range) @@ -941,28 +977,29 @@ def add_add_url_option(): if command == 'add-url': parser.set_usage("git bz add-url [-<N>] [options] <bug reference> [<since | <revision range>]"); add_num_option() - n_args = 2 + min_args = max_args = 2 elif command == 'apply': parser.set_usage("git bz apply [options] <bug reference>"); add_add_url_option() - n_args = 1 + min_args = max_args = 1 elif command == 'attach': parser.set_usage("git bz attach [-<N>] [options] <bug reference> [<since | <revision range>]"); add_add_url_option() add_num_option() - n_args = 2 + min_args = max_args = 2 elif command == 'file': parser.set_usage("git bz file [-<N>] [options] <product>/<component> [<since> | <revision range>]"); add_add_url_option() add_num_option() - n_args = 2 + min_args = 1 + max_args = 2 else: print >>sys.stderr, "Usage: git bz [add-url|apply|attach|file] [options]" sys.exit(1) global_options, args = parser.parse_args() -if len(args) != n_args: +if len(args) < min_args or len(args) > max_args: parser.print_usage() sys.exit(1) |