New API method to get pull information from the tracker
authorFrederic Massart <fmcell@gmail.com>
Tue, 1 Apr 2014 16:19:01 +0000 (00:19 +0800)
committerFrederic Massart <fmcell@gmail.com>
Tue, 1 Apr 2014 16:19:01 +0000 (00:19 +0800)
lib/jira.py

index a4f60db..44bf04f 100644 (file)
@@ -148,6 +148,30 @@ class Jira(object):
 
         return issue
 
+    def getPullInfo(self, key):
+        """Get the pull information organised by branch"""
+
+        fields = self.getIssue(key).get('named')
+        infos = {
+            'repo': None,
+            'branches': {}
+        }
+
+        for key, value in C.get('tracker.fieldnames').iteritems():
+            if key == 'repositoryurl':
+                infos['repo'] = fields.get(value)
+
+            elif key == 'master' or key.isdigit():
+                infos['branches'][key] = {
+                    'branch': fields.get(value['branch']),
+                    'compare': fields.get(value['diffurl'])
+                }
+            else:
+                # We don't know that field...
+                continue
+
+        return infos
+
     def getServerInfo(self):
         """Load the version info from the jira server using a rest api call"""
         resp = self.request('serverInfo')