You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/09/19 18:21:51 UTC
[19/41] git commit: [#6535] ticket:317 github comments import
[#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/db/5822
Commit: b766bdd0712b5d511f8aeb90afa8cfffcd5c1a21
Parents: fd9404a
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Aug 27 15:41:19 2013 +0300
Committer: Dave Brondsema <db...@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 = []