From b8ee5d06aa35ec5458bcac81ed96724b05e0732b Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Sep 23 2016 20:59:08 +0000 Subject: Added tag to import all issues as private by default Fixes https://pagure.io/pagure-importer/issue/40 --- diff --git a/README.md b/README.md index 2555119..b4beb33 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ 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. --help Show this message and exit. @@ -53,6 +54,10 @@ CLI tool for importing issues etc. from different sources like github to pagure This command will import all the tickets information with all tags to /tmp/foobar.git repository + $ pgimport fedorahosted https://fedorahosted.org/foobar --private + + This command will import all the fedorahosted tickets as private tickets in pagure + 3) The push command can be used to push a clone pagure ticket repo back to pagure. $ pgimport push foobar.git diff --git a/pagure_importer/commands/fedorahosted.py b/pagure_importer/commands/fedorahosted.py index f241c2c..89d4ccb 100644 --- a/pagure_importer/commands/fedorahosted.py +++ b/pagure_importer/commands/fedorahosted.py @@ -9,7 +9,8 @@ from pagure_importer.utils.fas import FASclient @app.command() @click.argument('project_url') @click.option('--tags', help="Import pagure tags:", is_flag=True) -def fedorahosted(project_url, tags): +@click.option('--private', help="By default make all issues private", is_flag=True) +def fedorahosted(project_url, tags, private): username = raw_input('Enter you FAS Username: ') password = getpass.getpass('Enter your FAS password: ') fasclient = FASclient(username, password, @@ -20,7 +21,7 @@ def fedorahosted(project_url, tags): repo_index = raw_input('Choose the import destination repo (default 1) : ') or 1 repo_name = repos[int(repo_index)-1] trac_importer = importer_trac.TracImporter(project_url, username, - password, fasclient, tags) + password, 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 2249cdd..7ac7042 100644 --- a/pagure_importer/utils/importer_trac.py +++ b/pagure_importer/utils/importer_trac.py @@ -12,12 +12,13 @@ class TracImporter(): '''Pagure importer for trac instance''' def __init__(self, project_url, username, password, - fasclient=None, tags=False): + fasclient=None, tags=False, private=False): self.url = project_url self.username = username self.password = password self.fas = fasclient self.tags = tags + self.private = private self.somebody = User(name='somebody', fullname='somebody', emails=['some@body.com']) self.reqid = 0 @@ -121,9 +122,13 @@ class TracImporter(): # Remove ',' between the tags and convert all tags to lower case pagure_issue_tags = list(set([j for k in [i.lower().split(',') for i in pagure_issue_tags] for j in k])) + pagure_issue_depends = [] pagure_issue_blocks = [] - pagure_issue_is_private = False + if self.private: + pagure_issue_is_private = True + else: + pagure_issue_is_private = False pagure_issue = Issue( id=ticket_id,