| |
@@ -0,0 +1,49 @@
|
| |
+ #!/usr/bin/env python
|
| |
+ # coding=utf-8
|
| |
+
|
| |
+ import requests
|
| |
+ from pagure_importer.utils.git import (
|
| |
+ clone_repo, push_delete_repo, update_git)
|
| |
+ from pagure_importer.utils import models
|
| |
+
|
| |
+
|
| |
+ class IntraPagureImporter():
|
| |
+ ''' For intra pagure imports of an issue '''
|
| |
+
|
| |
+ def __init__(self, source, issue_id):
|
| |
+ self.source = source
|
| |
+ self.source_issue_id = issue_id
|
| |
+ self.request_url = 'https://pagure.io/api/0/%s/issue/%s' % \
|
| |
+ (self.source, self.source_issue_id)
|
| |
+
|
| |
+ def import_issue(self, repo_name, repo_folder):
|
| |
+ ''' Import the issue from the source project and create commits
|
| |
+ locally '''
|
| |
+
|
| |
+ # get the issue
|
| |
+ issue = requests.get(self.request_url).json()
|
| |
+ issue_obj = models.Issue(
|
| |
+ id=None,
|
| |
+ title=issue.get('title'),
|
| |
+ content=issue.get('content'),
|
| |
+ status=issue.get('status'),
|
| |
+ date_created=issue.get('date_created'),
|
| |
+ user=issue.get('user'),
|
| |
+ private=issue.get('private'),
|
| |
+ attachment=issue.get('attachment'),
|
| |
+ tags=issue.get('tags'),
|
| |
+ depends=issue.get('depends'),
|
| |
+ blocks=issue.get('blocks'),
|
| |
+ assignee=issue.get('assignee'),
|
| |
+ close_status=issue.get('close_status'),
|
| |
+ comments=issue.get('comments'),
|
| |
+ milestone=issue.get('milestone'),
|
| |
+ custom_fields=issue.get('custom_fields'),
|
| |
+ )
|
| |
+ newpath, new_repo = clone_repo(repo_name, repo_folder)
|
| |
+
|
| |
+ # update the local git repo
|
| |
+ new_repo = update_git(issue_obj, newpath, new_repo)
|
| |
+
|
| |
+ # push and delete the cloned repo
|
| |
+ push_delete_repo(newpath, new_repo)
|
| |
vivek did u comment on your on code ?