From 2ccb39d6044045a411f14f51934d764c36f23b9a Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jul 25 2018 06:51:10 +0000 Subject: Do not create initial commit if the json indicates that Fixes #1 Signed-off-by: Chenxiong Qi --- diff --git a/fedscm_admin/pagure.py b/fedscm_admin/pagure.py index 1872be7..51c04d1 100644 --- a/fedscm_admin/pagure.py +++ b/fedscm_admin/pagure.py @@ -173,7 +173,8 @@ def get_scm_requests_git_url(url_type='ssh', username=None): return url -def new_project(namespace, repo, description, upstreamurl): +def new_project(namespace, repo, description, upstreamurl, + initial_commit=True): """ Create a new Pagure project :param namespace: a string representing the namespace to create the project @@ -181,6 +182,7 @@ def new_project(namespace, repo, description, upstreamurl): :param repo: a string of the project/repo name :param description: a string of the description of the project :param upstreamurl: a string of the URL of the upstream project + :param bool initial_commit: indicate whether to create an initial commit :return: None """ pagure_url = get_config_item(CONFIG, 'pagure_dist_git_url') @@ -193,9 +195,10 @@ def new_project(namespace, repo, description, upstreamurl): 'name': repo, 'description': description or 'The {0} package'.format(repo), 'url': upstreamurl or '', - 'create_readme': True, 'wait': True } + if initial_commit: + payload['create_readme'] = True click.echo('- Creating new pagure project {0}/{1}'.format(namespace, repo)) rv = requests_wrapper( diff --git a/fedscm_admin/utils.py b/fedscm_admin/utils.py index 02173dc..d1c75d6 100644 --- a/fedscm_admin/utils.py +++ b/fedscm_admin/utils.py @@ -263,7 +263,9 @@ def process_ticket(issue, force=False, auto_approve=False): if issue_body.get('action') == 'new_repo': prompt_for_new_repo(issue, issue_body, force=force, - auto_approve=auto_approve) + auto_approve=auto_approve, + initial_commit=issue_body.get( + 'initial_commit', True)) elif issue_body.get('action') == 'new_branch': prompt_for_new_branch(issue, issue_body, auto_approve=auto_approve) else: @@ -272,7 +274,7 @@ def process_ticket(issue, force=False, auto_approve=False): def prompt_for_new_repo(issue_json, issue_body_json, force=False, - auto_approve=False): + auto_approve=False, initial_commit=True): """ A helper function that prompts the user with information on a new repo ticket @@ -284,6 +286,7 @@ def prompt_for_new_repo(issue_json, issue_body_json, force=False, :param auto_approve: a boolean that determines if requests that don't require approval can be automatically approved and processed. This defaults to False. This currently does nothing. + :param bool initial_commit: indicate whether to create an initial commit. :return: None """ required_keys = [ @@ -437,7 +440,8 @@ def prompt_for_new_repo(issue_json, issue_body_json, force=False, # Create the Pagure repo fedscm_admin.pagure.new_project( - namespace, repo, description, upstreamurl) + namespace, repo, description, upstreamurl, + initial_commit=initial_commit) # If the branch requested isn't master, create that branch in git. The # master branch is already created at this point. if branch_name != 'master':