summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2015-02-10 09:36:23 +0000
committerOwen W. Taylor <otaylor@fishsoup.net>2015-02-12 15:09:34 -0500
commit2874294517f5867a2948db08e7ab03db073fb8c2 (patch)
tree063ac460fe4ed9e8daa327b0751fd55069cfbf7d
parent5ae7a500636ddc28bcf7a18427f388c8790623b3 (diff)
downloadgit-bz-2874294517f5867a2948db08e7ab03db073fb8c2.tar.gz
Add support for attaching patches on Bugzilla 4.2+
attachment.cgi requires a token field for Bugzilla 4.2 and later. (See https://bugzilla.mozilla.org/show_bug.cgi?id=703983) This token is not the same as the overall bug's token. So from we need to load attachment.cgi as a GET before every POST, which is a bit of a pain. https://bugzilla.gnome.org/show_bug.cgi?id=700502
-rwxr-xr-xgit-bz16
1 files changed, 16 insertions, 0 deletions
diff --git a/git-bz b/git-bz
index dbdef34..2b29641 100755
--- a/git-bz
+++ b/git-bz
@@ -1245,9 +1245,25 @@ class Bug(object):
print self.get_url()
def create_patch(self, description, comment, filename, data, obsoletes=[], status='none'):
+ # Bugzilla 4.2+ requires you to grab a fresh token from attachment.cgi.
+ url = "/attachment.cgi?bugid=" + str(self.id) + "&action=enter"
+
+ try:
+ response = self.server.send_request("GET", url)
+ except KeyboardInterrupt:
+ die("Failed to retrieve attachment form: user cancelled")
+ if response.status != 200:
+ die("Failed to retrieve attachment form: %d" % response.status)
+
+ token = re.search(r'<input type="hidden" name="token" value="(.+)">',
+ response.read())
+
+ # Build the new form.
fields = {}
fields['bugid'] = str(self.id)
fields['action'] = 'insert'
+ if token is not None:
+ fields['token'] = token.group(1)
fields['ispatch'] = '1'
fields['attachments.status'] = status
fields['description'] = description