From 4e241b068626b33adba88924b1aff80415c90942 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Mar 04 2017 10:39:28 +0000 Subject: [PATCH 1/2] Add status option while importing issues from github Signed-off-by: Vivek Anand --- diff --git a/pagure_importer/commands/github.py b/pagure_importer/commands/github.py index 9060d03..ee58c8d 100644 --- a/pagure_importer/commands/github.py +++ b/pagure_importer/commands/github.py @@ -17,9 +17,11 @@ from pagure_importer.utils.exceptions import ( @click.option('--project', prompt='Enter github project name like pypingou/pagure', help="Github project like pypingou/pagure") +@click.option('--status', default='all', + help="Status of issue/PR to be imported(open/closed/all)") @click.option('--nopush', is_flag=True, help="Do not push the result of pagure-importer back") -def github(username, project, nopush): +def github(username, project, nopush, status): ''' Command to import from github ''' password = click.prompt("Github Password", hide_input=True) gen_json = click.confirm( @@ -52,7 +54,7 @@ def github(username, project, nopush): except: raise GithubRepoNotFound( 'Repo not found, project name wrong') - github_importer.import_issues(repo) + github_importer.import_issues(repo, status=status) # update the local git repo new_repo = gitutils.update_git( diff --git a/pagure_importer/utils/importer_github.py b/pagure_importer/utils/importer_github.py index 866c750..553dd12 100644 --- a/pagure_importer/utils/importer_github.py +++ b/pagure_importer/utils/importer_github.py @@ -55,6 +55,12 @@ class GithubImporter(object): ''' Imports the issues on github for the given project ''' + status = status.lower() + if status not in ['all', 'open', 'closed']: + click.echo( + 'Wrong value of status, Should be either of open/closed/all') + exit() + repo_issues = repo.get_issues(state=status) issues_length = sum(1 for issue in repo_issues) From e4a9c162ad73c99b480b57dca69712156aa0c94c Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Mar 04 2017 14:56:15 +0000 Subject: [PATCH 2/2] github: use click's Choice instead of manual check Signed-off-by: Vivek Anand --- diff --git a/pagure_importer/commands/github.py b/pagure_importer/commands/github.py index ee58c8d..8cf12bf 100644 --- a/pagure_importer/commands/github.py +++ b/pagure_importer/commands/github.py @@ -17,7 +17,8 @@ from pagure_importer.utils.exceptions import ( @click.option('--project', prompt='Enter github project name like pypingou/pagure', help="Github project like pypingou/pagure") -@click.option('--status', default='all', +@click.option('--status', type=click.Choice(['all', 'open', 'closed']), + default='all', help="Status of issue/PR to be imported(open/closed/all)") @click.option('--nopush', is_flag=True, help="Do not push the result of pagure-importer back") diff --git a/pagure_importer/utils/importer_github.py b/pagure_importer/utils/importer_github.py index 553dd12..866c750 100644 --- a/pagure_importer/utils/importer_github.py +++ b/pagure_importer/utils/importer_github.py @@ -55,12 +55,6 @@ class GithubImporter(object): ''' Imports the issues on github for the given project ''' - status = status.lower() - if status not in ['all', 'open', 'closed']: - click.echo( - 'Wrong value of status, Should be either of open/closed/all') - exit() - repo_issues = repo.get_issues(state=status) issues_length = sum(1 for issue in repo_issues)