From 8836bbcb6c8d10fabc10dda1dc52a116ae652b13 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 22 Nov 2008 13:59:48 -0500 Subject: Make -b/--bugzilla a global option Allow specifying -b/--bugzilla for all subcommands and not just for for 'file' --- git-bz | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/git-bz b/git-bz index ad17ab1..747bd37 100755 --- a/git-bz +++ b/git-bz @@ -319,7 +319,10 @@ def get_body(commit): # Per-tracker configuration variables # =================================== -def get_default_tracker(): +def get_tracker(): + if global_options.bugzilla != None: + return global_options.bugzilla + try: return git.config('bz.default-tracker', get=True) except CalledProcessError: @@ -422,7 +425,7 @@ def resolve_bug_reference(bug_reference): tracker = bug_reference[0:colon] id = bug_reference[colon + 1:] else: - tracker = get_default_tracker() + tracker = get_tracker() id = bug_reference host = resolve_host_alias(tracker) @@ -903,12 +906,7 @@ def do_file(product_component, since_or_revision_range): description = "".join(lines[i + 1:]).strip() - if global_options.bugzilla: - tracker = global_options.bugzilla - else: - tracker = get_default_tracker() - - bug = Bug.create(tracker, product, component, summary, description) + bug = Bug.create(get_tracker(), product, component, summary, description) if global_options.add_url: add_url(bug, commits) @@ -925,6 +923,8 @@ else: sys.argv[1:2] = [] parser = OptionParser() +parser.add_option("-b", "--bugzilla", metavar="HOST_OR_ALIAS", + help="bug tracker to use") def add_num_option(): parser.add_option("", "--num", metavar="N", @@ -953,8 +953,6 @@ elif command == 'attach': n_args = 2 elif command == 'file': parser.set_usage("git bz file [-] [options] / [ | ]"); - parser.add_option("-b", "--bugzilla", metavar="HOST_OR_ALIAS", - help="bug tracker to file bug on") add_add_url_option() add_num_option() n_args = 2 -- cgit