From 795ff39a29df7fdc5b854bd77534bc1939feebc7 Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Wed, 26 Aug 2009 23:25:15 -0500 Subject: Improve error handling when bug reference is incorrect If the user specifies the bug url on the command line but the url violates our assumptions, git-bz doesn't currently handle it well. For instance, the following commandline invocation: git bz attach http://bugzilla.foo.org HEAD will fail the regex that checks whether it is a bugzilla url (since it is missing show_bug.cgi), so it will interpret it as a 'alias:1234'-style reference. 'http' is interpreted as the alias, but when that is not found in the git config, it will attempt to look up a browser cookie for the host 'http'. That will also fail, but it will report a misleading error which is something like: Please log in to 'http' in Firefox This patch just does a little sanity checking that the bug id is a number and aborts with a slightly more helpful error message if that is not true. --- git-bz | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-bz b/git-bz index 751af8d..e91cce3 100755 --- a/git-bz +++ b/git-bz @@ -481,6 +481,9 @@ def resolve_bug_reference(bug_reference): tracker = get_tracker() id = bug_reference + if not id.isdigit(): + die("Invalid bug reference '%s'" % bug_reference) + host = resolve_host_alias(tracker) https = tracker_uses_https(tracker) -- cgit v1.2.3