#76 Support for intra pagure moving of an issue
Opened 7 years ago by vivekanand1101. Modified 7 years ago

file modified
+14
@@ -124,6 +124,20 @@ 

      $ pgimport push foobar.git

  

  

+ ### Migrate a ticket from one pagure project to other

+ ---

+ 1)  Clone the tickets git repository of the project you want to the issue be transfered to using:

+      $ pgimport clone ssh://git@pagure.io/tickets/foobar.git

+ 

+    This will clone the pagure foobar repository into the default set /tmp directory as /tmp/foobar.git

+ 

+ 2)  Use the ```pagure``` command to get the issue via the pagure api. Specify ```source``` and ```issue_id```.

+      $ pgimport pagure --source abcxyz --issue_id 567

+ 

+ 3) The last command will create the issue to the local git repo you just cloned. Now push that repo to

+     create the issue on the destination project using:

+      $ pgimport push /tmp/foobar.git

+ 

  ### Tools used:

  ---

  1. [PyGithub](https://github.com/PyGithub/PyGithub) - a python library for [github](https://github.com/) api.

file modified
+1
@@ -18,6 +18,7 @@ 

  import pagure_importer.commands.clone

  import pagure_importer.commands.push

  import pagure_importer.commands.mkconfig

+ import pagure_importer.commands.pagure

  

  if __name__ == '__main__':

      app()

@@ -0,0 +1,30 @@ 

+ #!/usr/bin/env python

+ # coding=utf-8

+ 

+ import click

+ import pagure_importer

+ from pagure_importer.app import app, REPO_PATH

+ from pagure_importer.utils import intra_pagure as ip

+ 

+ 

+ @app.command()

+ @click.option('--source', prompt="Source project with namespace and username")

+ @click.option('--issue_id', prompt="Issue id of the issue on source project")

+ def pagure(source, issue_id):

+     ''' Command for intra project import of an issue '''

+ 

+     repos = pagure_importer.utils.display_repo()

+     if repos:

+         repo_index = click.prompt('Choose the import destination repo ',

+                                   default=1)

+         repo_name = repos[int(repo_index)-1]

+         intra_importer = ip.IntraPagureImporter(

+                 source=source,

+                 issue_id=issue_id

+         )

+         intra_importer.import_issue(

+                 repo_name=repo_name,

+                 repo_folder=REPO_PATH

+         )

+     else:

+         click.echo('No ticket repository found. Use pgimport clone command')

@@ -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' % \

vivek did u comment on your on code ?

Yup. I had doubts about these 2. So, i thought why not? :p

Haha cool :)

+             (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'),

do you think you can get attachments like this?

+             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)

rebased

7 years ago

do you think you can get attachments like this?

should we just call it pagure ?

vivek did u comment on your on code ?

Yup. I had doubts about these 2. So, i thought why not? :p

If you want to rebase, edit the name to be pagure and maybe add some usage example in the README.
We can merge this.

Then we can raise issue against it :chipmunk:

rebased

7 years ago

1 new commit added

  • add documentation on how to use intra pagure importer
7 years ago

commenting so I can be notified of new updates/comments

rebased onto 2b35b25

6 years ago

rebased onto 1477db6

6 years ago