From 20a5009a593408bddf13ab5e466fb1011acce7bb Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 15 Jul 2011 14:25:54 -0400 Subject: components: new command to list the components of a product eg git bz components -b bugzilla.gnome.org gnome-shell or just git bz components if you have defaults configured https://bugzilla.gnome.org/show_bug.cgi?id=654693 --- git-bz | 40 +++++++++++++++++++++++++++++++++++++++- git-bz.txt | 9 +++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/git-bz b/git-bz index 0d76945..6b2a52b 100755 --- a/git-bz +++ b/git-bz @@ -2030,6 +2030,38 @@ def do_push(*args): bug = Bug.load(handle) edit_bug(bug, commits) +def do_components(*args): + tracker = get_tracker() + host = resolve_host_alias(tracker) + https = tracker_uses_https(tracker) + path = tracker_get_path(tracker) + auth_user = tracker_get_auth_user(tracker) + auth_password = tracker_get_auth_password(tracker) + + server = get_bug_server(host, path, https, auth_user, auth_password) + + if len(args) == 1: + product = args[0] + else: + product = get_default_product() + if not product: + die(" not specified and no default product is configured" + PRODUCT_COMPONENT_HELP) + + try: + response = server.get_xmlrpc_proxy().Product.get({ 'names': product }) + except xmlrpclib.Fault, e: + die(e.faultString) + except xmlrpclib.ProtocolError, e: + die("Unable to retrieve components: %s" % e.errmsg) + + products = response['products'] + if len(products) == 0: + die("No such product '%s' on %s." % (product, host)) + + product = response['products'][0] + for component in product['components']: + print "%s" % component['name'] + ################################################################################ if len(sys.argv) > 1: @@ -2070,6 +2102,10 @@ elif command == 'attach': add_edit_option() min_args = 1 max_args = 2 +elif command == 'components': + parser.set_usage("git bz components [options] []"); + min_args = 0 + max_args = 1 elif command == 'edit': parser.set_usage("git bz edit [options] ( | | )"); parser.add_option("", "--pushed", action="store_true", @@ -2091,7 +2127,7 @@ elif command == 'push': min_args = 0 max_args = 1000 # no max else: - print >>sys.stderr, "Usage: git bz [add-url|apply|attach|edit|file|push] [options]" + print >>sys.stderr, "Usage: git bz [add-url|apply|attach|components|edit|file|push] [options]" sys.exit(1) global_options, args = parser.parse_args() @@ -2109,6 +2145,8 @@ elif command == 'apply': do_apply(*args) elif command == 'attach': do_attach(*args) +elif command == 'components': + do_components(*args) elif command == 'edit': if global_options.pushed: exit diff --git a/git-bz.txt b/git-bz.txt index 6ffcdd9..848c4c6 100644 --- a/git-bz.txt +++ b/git-bz.txt @@ -11,6 +11,7 @@ SYNOPSIS 'git bz add-url' ( | ) 'git bz apply' [-n | --no-add-url] 'git bz attach' [-n | --no-add-url] [-e |--edit] [] ( | ) +'git bz components' [] 'git bz edit' ( | | ) 'git bz edit' (--pushed | --fix | ) 'git bz file' [-n | --no-add-url] [[]/] ( | ) @@ -180,6 +181,14 @@ git bz attach bugzilla.gnome.org:1234 HEAD git bz attach bugzilla.gnome.org:1234 b50ea9bd^.. ---------------------------------------- +components +~~~~~~~~~~ + +'git bz components' [] + +Prints out the list of components for the given product (or the +default product if none is given on the command line). + edit ~~~~ -- cgit v1.2.3