From 3802a9b29838faa5d595c95d00e1e82645bdc650 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Oct 23 2016 16:08:26 +0000 Subject: [PATCH 1/2] Added flag for issue offset, that way we can import issue to pagure even when the pagure project already contains issues --- diff --git a/pagure_importer/commands/fedorahosted.py b/pagure_importer/commands/fedorahosted.py index 923b363..17b21f6 100644 --- a/pagure_importer/commands/fedorahosted.py +++ b/pagure_importer/commands/fedorahosted.py @@ -14,7 +14,9 @@ from pagure_importer.utils.fas import FASclient help="FAS username") @click.option('--password', prompt=True, hide_input=True, help="FAS password") -def fedorahosted(project_url, tags, private, username, password): +@click.option('--offset', default=0, + help='Number of issue in pagure before import') +def fedorahosted(project_url, tags, private, username, password, offset): fasclient = FASclient(username, password, 'https://admin.fedoraproject.org/accounts') project_url = project_url + '/login/jsonrpc' @@ -24,8 +26,8 @@ def fedorahosted(project_url, tags, private, username, password): default=1) repo_name = repos[int(repo_index)-1] trac_importer = importer_trac.TracImporter(project_url, username, - password, fasclient, tags, - private) + password, offset, fasclient, + tags, private) trac_importer.import_issues(repo_name=repo_name, repo_folder=REPO_PATH) else: click.echo('No ticket repository found. Use pgimport clone command') diff --git a/pagure_importer/utils/importer_trac.py b/pagure_importer/utils/importer_trac.py index b922593..4a5ab23 100644 --- a/pagure_importer/utils/importer_trac.py +++ b/pagure_importer/utils/importer_trac.py @@ -13,7 +13,7 @@ from pagure_importer.utils.models import User, Issue, IssueComment class TracImporter(): ''' Pagure importer for trac instance ''' - def __init__(self, project_url, username, password, + def __init__(self, project_url, username, password, offset, fasclient=None, tags=False, private=False): ''' Instantiate a TracImporter object ''' @@ -23,6 +23,7 @@ class TracImporter(): self.fas = fasclient self.tags = tags self.private = private + self.offset = offset self.somebody = User(name='somebody', fullname='somebody', emails=['some@body.com']) self.reqid = 0 @@ -144,7 +145,7 @@ class TracImporter(): pagure_issue_is_private = False pagure_issue = Issue( - id=ticket_id, + id=ticket_id + self.offset, title=pagure_issue_title, content=pagure_issue_content, status=issue_status, From 5c79dcda08d3308f871281d0bf68d923d0f5e2e5 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Oct 23 2016 16:08:26 +0000 Subject: [PATCH 2/2] Updated README with new CLI options --- diff --git a/README.md b/README.md index b4beb33..ec1a8b1 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,9 @@ CLI tool for importing issues etc. from different sources like github to pagure Options: --tags Import pagure tags as well. --private By default make all issues private. + --username TEXT FAS username + --password TEXT FAS password + --offset INTEGER Number of issue in pagure before import --help Show this message and exit. @@ -58,6 +61,17 @@ CLI tool for importing issues etc. from different sources like github to pagure This command will import all the fedorahosted tickets as private tickets in pagure + $ pgimport fedorahosted https://fedorahosted.org/foobar --offset 10 + + This command will import all the fedorahosted tickets starting using their + former trac ID + the offset number 10 in this example. This is usefull for project + which already have issues in pagure before import. + + $ pgimport fedorahosted https://fedorahosted.org/foobar --username foo --password bar + + This command will run the import using the username and password provided in the command + line without prompting the user. This is usefull to use pgimport in a script. + 3) The push command can be used to push a clone pagure ticket repo back to pagure. $ pgimport push foobar.git @@ -69,7 +83,7 @@ CLI tool for importing issues etc. from different sources like github to pagure $ 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 + This will clone the pagure foobar repository into the default set /tmp directory as /tmp/foobar.git 2) The github command can be used to import issues from a github project to pagure