incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [19/50] git commit: [#6535] ticket:317 github comments import
Date Tue, 24 Sep 2013 17:07:58 GMT
[#6535] ticket:317 github comments import

Conflicts:
	ForgeImporters/forgeimporters/github/__init__.py


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b766bdd0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b766bdd0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b766bdd0

Branch: refs/heads/cj/6422
Commit: b766bdd0712b5d511f8aeb90afa8cfffcd5c1a21
Parents: fd9404a
Author: Anton Kasyanov <mind1master@gmail.com>
Authored: Tue Aug 27 15:41:19 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Sep 19 14:46:50 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/__init__.py |  6 ++++++
 ForgeImporters/forgeimporters/github/tracker.py  | 15 +++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b766bdd0/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index 13d32e4..438fc8a 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -56,3 +56,9 @@ class GitHubProjectExtractor(base.ProjectExtractor):
         issues.sort(key=lambda x: x['number'])
         for issue in issues:
             yield (issue['number'], issue)
+
+    def iter_comments(self, issue):
+        comments_url = issue['comments_url']
+        comments = self.get_page(comments_url)
+        for comment in comments:
+            yield comment

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b766bdd0/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index af5363d..3266cc8 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -47,7 +47,7 @@ class GitHubTrackerImporter(ToolImporter):
                         custom_fields=dict(),
                         ticket_num=ticket_num)
                     self.process_fields(ticket, issue)
-                    #self.process_comments(ticket, issue)
+                    self.process_comments(extractor, ticket, issue)
                     session(ticket).flush(ticket)
                     session(ticket).expunge(ticket)
                 #app.globals.custom_fields = self.get_milestones()
@@ -82,14 +82,17 @@ class GitHubTrackerImporter(ToolImporter):
                 )
         ticket.labels = [label['name'] for label in issue['labels']]
 
-    def process_comments(self, ticket, issue):
-        for comment in issue.iter_comments():
+    def process_comments(self, extractor, ticket, issue):
+        for comment in extractor.iter_comments(issue):
+            body, attachments = self._get_attachments(comment['body'])
+            if comment['user']:
+                body += u'\n*Originally posted by: {}*'.format(comment['user']['login'])
             p = ticket.discussion_thread.add_post(
-                    text = comment.annotated_text,
+                    text = body,
                     ignore_security = True,
-                    timestamp = datetime.strptime(comment.created_date, '%c'),
+                    timestamp = datetime.strptime(comment['created_at'], '%Y-%m-%dT%H:%M:%SZ'),
                 )
-            p.add_multiple_attachments(comment.attachments)
+            p.add_multiple_attachments(attachments)
 
     def get_milestones(self):
         custom_fields = []


Mime
View raw message