From 857823e95e4ca187143f1e96b2c033aaf67c7d5c Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Aug 16 2018 05:26:42 +0000 Subject: New option to request a repo without an initial commit A new option --no-initial-commit is added to request a repository without an initial commit. When specified, a new item is added to ticket, which looks like { "action": "new_repo", "branch": "master", ... "initial_commit": false } initial_commit with value false indicates not create the initial commit. Fixes #215 Signed-off-by: Chenxiong Qi --- diff --git a/conf/bash-completion/fedpkg.bash b/conf/bash-completion/fedpkg.bash index d0bf8fb..4aa6ad6 100644 --- a/conf/bash-completion/fedpkg.bash +++ b/conf/bash-completion/fedpkg.bash @@ -193,7 +193,7 @@ _fedpkg() options_string="--sl --repo" ;; request-repo) - options="--exception" + options="--exception --no-initial-commit" options_string="--description --monitor --upstreamurl --summary" options_namespace="--namespace" ;; diff --git a/fedpkg/cli.py b/fedpkg/cli.py index 38e737c..b3ee192 100644 --- a/fedpkg/cli.py +++ b/fedpkg/cli.py @@ -300,6 +300,10 @@ Another example to request a module foo: '--exception', action='store_true', help='The package is an exception to the regular package review ' 'process (specifically, it does not require a Bugzilla bug)') + request_repo_parser.add_argument( + '--no-initial-commit', + action='store_true', + help='Do not include an initial commit in the repository.') request_repo_parser.set_defaults(command=self.request_repo) def register_request_tests_repo(self): @@ -692,6 +696,7 @@ targets to build the package for a particular stream. exception=self.args.exception, name=self.name, config=self.config, + initial_commit=not self.args.no_initial_commit, ) def request_tests_repo(self): @@ -707,7 +712,7 @@ targets to build the package for a particular stream. @staticmethod def _request_repo(repo_name, ns, description, name, config, branch=None, summary=None, upstreamurl=None, monitor=None, bug=None, - exception=None, anongiturl=None): + exception=None, anongiturl=None, initial_commit=True): """ Implementation of `request_repo`. Submits a request for a new dist-git repo. @@ -789,6 +794,8 @@ targets to build the package for a particular stream. 'summary': summary or summary_from_bug, 'upstreamurl': upstreamurl or '' } + if not initial_commit: + ticket_body['initial_commit'] = False ticket_body = json.dumps(ticket_body, indent=True) ticket_body = '```\n{0}\n```'.format(ticket_body) diff --git a/test/test_cli.py b/test/test_cli.py index 20eae56..201aa00 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -815,6 +815,23 @@ class TestRequestRepo(CliTestCase): except rpkgError as error: self.assertEqual(str(error), expected_error) + @patch('requests.post') + def test_request_repo_without_initial_commit( + self, mock_request_post, mock_bz): + """Tests a request-repo call with --no-initial-commit""" + + cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, + 'request-repo', '--no-initial-commit', '--exception'] + cli = self.get_cli(cli_cmd) + cli.request_repo() + + # Get the data that was submitted to Pagure + post_data = mock_request_post.call_args_list[0][1]['data'] + actual_issue_content = json.loads(json.loads( + post_data)['issue_content'].strip('```')) + self.assertIn('initial_commit', actual_issue_content) + self.assertFalse(actual_issue_content['initial_commit']) + class TestRequestBranch(CliTestCase): """Test the request-branch command"""