# HG changeset patch # User Santeri Piippo # Date 1402259884 -10800 # Node ID 7dbc04a61376f3321805c97c490b73f7d7b49d4d # Parent b7f23f86cb2c4902098a76888d2e94fab113d799 - removed the rest of the python thing, that doesn't work right diff -r b7f23f86cb2c -r 7dbc04a61376 pull-request.sh --- a/pull-request.sh Sun Jun 08 23:26:40 2014 +0300 +++ b/pull-request.sh Sun Jun 08 23:38:04 2014 +0300 @@ -78,10 +78,6 @@ head=$(echo $heads |cut -d ' ' -f $head_index) title=$(hg log -r ${head} -r tip --template '{desc}') source_repo=$(hg paths default |rev |cut -d '/' -f 1,2 |rev) -bturl=$(grep bturl $selfpath/settings.cfg |cut -d ' ' -f 2) -btuser=$(grep btuser $selfpath/settings.cfg |cut -d ' ' -f 2) -btpass=$(grep btpass $selfpath/settings.cfg |cut -d ' ' -f 2) -ticket=$(hg log -r $head --template '{bookmarks}' |cut -f 2 -d '|') while [ "$(echo $title |wc -c)" -gt "255" ] do diff -r b7f23f86cb2c -r 7dbc04a61376 pullreq_to_mantisbt.py --- a/pullreq_to_mantisbt.py Sun Jun 08 23:26:40 2014 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -#!/usr/bin/env python - -import json -import urllib -import urllib2 -import sys -import re -from suds.xsd.doctor import Import -from suds.xsd.doctor import ImportDoctor -from suds.client import Client - -bturl=sys.argv[1] -btuser=sys.argv[2] -btpass=sys.argv[3] -ticket=sys.argv[4] -bitbucketjson=sys.argv[5] -titlefile=sys.argv[6] - -with open (bitbucketjson, 'r') as fp: - jsondata = json.loads (fp.read()) - -with open (titlefile, 'r') as fp: - title = fp.read() - -regex = re.compile (r'^https://api\.bitbucket\.org/2\.0/repositories/([^/]+)/([^/]+)/pullrequests/([0-9]+)$') -match = regex.match (jsondata["links"]["self"]["href"]) - -if not match: - print "Bad JSON input (couldn't regex the pull request URL)" - quit() - -suds_import = Import ('http://schemas.xmlsoap.org/soap/encoding/', \ - 'http://schemas.xmlsoap.org/soap/encoding/') -suds_client = Client ('https://%s/api/soap/mantisconnect.php?wsdl' % bturl, \ - plugins=[ImportDoctor (suds_import)]) - -data={} -data["status"]={} -data["status"]["id"] = 60 -suds_client.service.mc_issue_update (btuser, btpass, ticket, data) -note = {} -note["text"] = "https://bitbucket.org/%s/%s/pull-request/%s" % (match.group(1), match.group(2), match.group(3)) -noteid = suds_client.service.mc_issue_note_add (btuser, btpass, ticket, note) -print "Pull request notice posted to mantisbt: https://%s/view.php?id=%s#c%s" % (bturl, ticket, noteid)