[bts-link] 01/02: Add some support for Allura trackers, used in the new SourceForge
Olivier Berger
obergix at moszumanska.debian.org
Mon Oct 19 15:02:43 UTC 2015
This is an automated email from the git hooks/post-receive script.
obergix pushed a commit to branch only-allura
in repository bts-link.
commit c4f4984e0079a120f60149a15fa8e37d4d42f1ea
Author: Olivier Berger <olivier.berger at telecom-sudparis.eu>
Date: Mon Oct 19 15:25:05 2015 +0200
Add some support for Allura trackers, used in the new SourceForge
---
btslink.yaml | 4 +++
remote/allura.py | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
remote/base.py | 2 +-
3 files changed, 99 insertions(+), 1 deletion(-)
diff --git a/btslink.yaml b/btslink.yaml
index cc6d3a8..544f619 100644
--- a/btslink.yaml
+++ b/btslink.yaml
@@ -412,6 +412,10 @@ remotes:
savannah-nongnu:
uri: http://savannah.nongnu.org/bugs/
uri-re: https?://savannah.nongnu.org/bugs/(?:index.php|)\?(?:(?:.*&)*item_id=)?([0-9]+)
+ allura:
+ sourceforgeallura:
+ uri: https://sourceforge.net/p
+ uri-re: https?://sourceforge.net/p/(?:.*)/bugs/([0-9]+)/?
sourceforge2:
sourceforge:
uri: http://sf.net/tracker/
diff --git a/remote/allura.py b/remote/allura.py
new file mode 100644
index 0000000..de2f13d
--- /dev/null
+++ b/remote/allura.py
@@ -0,0 +1,94 @@
+# vim:set encoding=utf-8:
+###############################################################################
+# Copyright:
+# © 2006 Pierre Habouzit <madcoder at debian.org>
+# 2015 Olivier Berger <olivier.berger at telecom-sudparis.eu>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The names of its contributors may not be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+###############################################################################
+
+# Allura trackers support (Apache Allura : https://allura.apache.org/)
+
+from __init__ import *
+import re, urllib2, json, string
+
+class AlluraTrackerData:
+ def __init__(self, uri, urlcomponents):
+ self.id = urlcomponents or failwith(uri, "Allura: no id : %s" % str(urlcomponents))
+
+ status = None
+ resolution = None
+
+ # We access the REST API to fetch JSON description of the bug
+ apiurl = "%(uri)s/rest/p/%(project)s/%(type)s/%(id)s/" % urlcomponents
+
+ req = urllib2.Request(apiurl)
+ data = json.load(urllib2.urlopen(req))
+
+ ticketdata = data.get('ticket')
+ if data:
+ status = ticketdata.get('status')
+
+ self.status = status or failwith(uri, "Allura", exn=NoStatusExn)
+
+ # I hope the status are more or less constant among projects, but not sure
+ if status == 'closed-duplicate':
+ resolution = 'duplicate'
+
+ self.resolution = resolution
+
+ if self.resolution == 'duplicate':
+ raise DupeExn(uri)
+
+
+class RemoteAlluraTracker(RemoteBts):
+ '''
+ Support for Allura bug trackers
+ '''
+ def __init__(self, cnf):
+
+ RemoteBts.__init__(self, cnf, None, None, AlluraTrackerData)
+
+ # override base class method to extract the URL components as useful as for _getUri
+ def extractBugid(self, uri):
+ bugre = re.compile(r"^(?P<uri>.*)/p/(?P<project>.*)/(?P<type>.*)/(?P<id>[0-9]+)/?$")
+ res = bugre.match(uri)
+ if res:
+ return res.groupdict()
+ else:
+ return None
+
+ # return a meaningful uri
+ def _getUri(self, urlcomponents):
+ return "%(uri)s/p/%(project)s/%(type)s/%(id)s/" % urlcomponents
+
+ def isClosing(self, status, resolution):
+ # All status starting by 'closed' are matched, again I hope the status are more or less constant among projects, but not sure
+ return status and (string.find(status, "closed") == 0)
+
+ def isWontfix(self, status, resolution):
+ # Again I hope the status are more or less constant among projects, but not sure
+ return status and (string.find(status, "closed-wont-fix") == 0)
+
+RemoteBts.register('allura', RemoteAlluraTracker)
diff --git a/remote/base.py b/remote/base.py
index f122b95..d27d410 100644
--- a/remote/base.py
+++ b/remote/base.py
@@ -394,4 +394,4 @@ class RemoteBts:
return data.id
# Import all bugtracker classes which will in turn register with RemoteBts.register()
-import berlios, bitbucket, bugzilla, gnats, launchpad, mantis, rt, savane, sourceforge, trac, gforge, github, googlecode, roundup, misc, flyspray, jira, redmine
+import allura, berlios, bitbucket, bugzilla, gnats, launchpad, mantis, rt, savane, sourceforge, trac, gforge, github, googlecode, roundup, misc, flyspray, jira, redmine
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bts-link/bts-link.git
More information about the bts-link-commits
mailing list