From 5e2253b56a842540d5609272ed703361ec8d47e1 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Nov 08 2016 19:30:14 +0000 Subject: [PATCH 1/3] Make the comment attachment a list to manage more than one attachment per comment Signed-off-by: Clement Verna --- diff --git a/pagure_importer/utils/importer_trac.py b/pagure_importer/utils/importer_trac.py index 4a5ab23..c0e2f27 100644 --- a/pagure_importer/utils/importer_trac.py +++ b/pagure_importer/utils/importer_trac.py @@ -70,12 +70,13 @@ class TracImporter(): # add all the comments to the issue object for key in comments: if comments[key].attachment: - attach_name = comments[key].attachment - project = repo_name.replace('.git', '') - filename = get_secure_filename( - pagure_issue.attachment[attach_name], attach_name) - url = '/%s/issue/raw/files/%s' % (project, filename) - comments[key].comment += '\n[%s](%s)' % (attach_name, url) + for file in comments[key].attachment: + attach_name = file + project = repo_name.replace('.git', '') + filename = get_secure_filename( + pagure_issue.attachment[attach_name], attach_name) + url = '/%s/issue/raw/files/%s' % (project, filename) + comments[key].comment += '\n[%s](%s)' % (attach_name, url) pagure_issue.comments.append(comments[key].to_json()) # update the local git repo new_repo = update_git(pagure_issue, newpath, new_repo) @@ -219,7 +220,7 @@ class TracImporter(): id=None, comment='attachment', date_created=ts, - attachment=comment[4], + attachment=[comment[4]], user=pagure_issue_comment_user.to_json()) return comments From db0384ad453da2749916680dc0e48bac0211725c Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Nov 08 2016 19:30:14 +0000 Subject: [PATCH 2/3] File variable is not needed Signed-off-by: Clement Verna --- diff --git a/pagure_importer/utils/importer_trac.py b/pagure_importer/utils/importer_trac.py index c0e2f27..b842078 100644 --- a/pagure_importer/utils/importer_trac.py +++ b/pagure_importer/utils/importer_trac.py @@ -70,9 +70,8 @@ class TracImporter(): # add all the comments to the issue object for key in comments: if comments[key].attachment: - for file in comments[key].attachment: - attach_name = file - project = repo_name.replace('.git', '') + project = repo_name.replace('.git', '') + for attach_name in comments[key].attachment: filename = get_secure_filename( pagure_issue.attachment[attach_name], attach_name) url = '/%s/issue/raw/files/%s' % (project, filename) From 9db2010b691d27dbd9ef3665f4b9c809599041f8 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Nov 08 2016 19:30:14 +0000 Subject: [PATCH 3/3] Added link to copr --- diff --git a/README.md b/README.md index 7773af3..5e8b02f 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ CLI tool for importing issues etc. from different sources like github to pagure --- * Install it using ```pip``` . ```pip install pagure_importer``` +* Install it using [copr](https://copr.fedorainfracloud.org/coprs/cverna/pagure-importer/). +``` + $ dnf copr enable cverna/pagure-importer + $ dnf install python2-pagure_importer +``` + ## How to run --- 0. Clone the issue tracker for issues from pagure. Use: ```pgimport clone ssh://git@pagure.io/tickets/foobar.git```