From 68d1ac88821a60e9d20fa1e987ed314c4341174a Mon Sep 17 00:00:00 2001 From: Nikola Forró Date: Mar 18 2025 12:15:47 +0000 Subject: `request-repo`: add `--onboard-packit` argument This is part of this Fedora change: https://fedoraproject.org/wiki/Changes/AutomatedPackitOnboarding Merges: https://pagure.io/fedpkg/pull-request/586 Signed-off-by: Nikola Forró --- diff --git a/fedpkg/cli.py b/fedpkg/cli.py index 461c085..209681a 100644 --- a/fedpkg/cli.py +++ b/fedpkg/cli.py @@ -372,6 +372,13 @@ class fedpkgClient(cliClient): '--no-initial-commit', action='store_true', help='Do not include an initial commit in the repository.') + packit_onboarding_choices = ['no', 'pull-request', 'push'] + request_repo_parser.add_argument( + '--onboard-packit', + help='Whether to generate a default Packit configuration ' + 'for the package and open a pull request against or push ' + 'directly to the newly created dist-git repository', + choices=packit_onboarding_choices, default=packit_onboarding_choices[0]) request_repo_parser.set_defaults(command=self.request_repo) def register_request_tests_repo(self): @@ -975,6 +982,7 @@ class fedpkgClient(cliClient): name=self.name, config=self.config, initial_commit=not self.args.no_initial_commit, + onboard_packit=self.args.onboard_packit, ) def request_tests_repo(self): @@ -993,7 +1001,7 @@ class fedpkgClient(cliClient): def _request_repo(logger, repo_name, ns, description, name, config, branch=None, summary=None, upstreamurl=None, monitor=None, bug=None, exception=None, anongiturl=None, - initial_commit=True): + initial_commit=True, onboard_packit=None): """ Implementation of `request_repo`. Submits a request for a new dist-git repo. @@ -1028,6 +1036,11 @@ class fedpkgClient(cliClient): `self.args.exception`. :param anongiturl: A string with the name of the anonymous git url. Typically the value of `self.cmd.anongiturl`. + :param onboard_packit: A string, whether to generate a default + Packit configuration for the package and open a pull request + against or push directly to the newly created dist-git repository. + Accepted values are `no`, `pull-request` and `push`. + Typically takes the value of `self.args.onboard_packit`. :return: None """ @@ -1063,6 +1076,7 @@ class fedpkgClient(cliClient): 'bug_id': bug or '', 'monitor': 'no-monitoring', 'namespace': 'tests', + 'onboard_packit': 'no', 'repo': repo_name, 'description': description, 'upstreamurl': '', @@ -1079,6 +1093,7 @@ class fedpkgClient(cliClient): 'exception': exception, 'monitor': monitor, 'namespace': ns, + 'onboard_packit': onboard_packit, 'repo': repo_name, 'summary': summary or summary_from_bug, 'upstreamurl': upstreamurl or '' @@ -1284,6 +1299,7 @@ class fedpkgClient(cliClient): exception=True, name=name, config=config, + onboard_packit='no', ) fedpkgClient._request_branch( logger=logger, diff --git a/test/test_cli.py b/test/test_cli.py index cb25ab7..a89f044 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -505,6 +505,7 @@ class TestRequestRepo(CliTestCase): 'exception': False, 'monitor': 'monitoring', 'namespace': 'rpms', + 'onboard_packit': 'no', 'repo': 'testpkg', 'summary': 'a description', 'upstreamurl': '' @@ -542,6 +543,7 @@ class TestRequestRepo(CliTestCase): 'exception': False, 'monitor': 'monitoring', 'namespace': 'rpms', + 'onboard_packit': 'no', 'repo': 'nethack', 'summary': ('A rogue-like single player dungeon exploration ' 'game'), @@ -582,6 +584,7 @@ class TestRequestRepo(CliTestCase): 'exception': False, 'monitor': 'monitoring', 'namespace': 'modules', + 'onboard_packit': 'no', 'repo': 'nethack', 'summary': (''), 'upstreamurl': '' @@ -623,6 +626,7 @@ class TestRequestRepo(CliTestCase): 'exception': False, 'monitor': 'monitoring', 'namespace': 'container', + 'onboard_packit': 'no', 'repo': 'nethack', 'summary': ('A rogue-like single player dungeon exploration ' 'game'), @@ -652,7 +656,7 @@ class TestRequestRepo(CliTestCase): cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, 'request-repo', 'nethack', '1441813', '-d', 'a description', '-s', 'a summary', '-m', 'no-monitoring', - '-u', 'http://test.local'] + '-u', 'http://test.local', '--onboard-packit', 'pull-request'] cli = self.get_cli(cli_cmd) cli.request_repo() @@ -664,6 +668,7 @@ class TestRequestRepo(CliTestCase): 'exception': False, 'monitor': 'no-monitoring', 'namespace': 'rpms', + 'onboard_packit': 'pull-request', 'repo': 'nethack', 'summary': 'a summary', 'upstreamurl': 'http://test.local' @@ -700,6 +705,7 @@ class TestRequestRepo(CliTestCase): 'exception': True, 'monitor': 'monitoring', 'namespace': 'rpms', + 'onboard_packit': 'no', 'repo': 'nethack', 'summary': '', 'upstreamurl': '' @@ -1259,6 +1265,7 @@ class TestRequestBranch(CliTestCase): u'exception': True, u'monitor': u'no-monitoring', u'namespace': u'modules', + u'onboard_packit': u'no', u'repo': u'nethack', u'summary': summary, u'upstreamurl': u'' @@ -1565,6 +1572,7 @@ class TestRequestTestsRepo(CliTestCase): 'bug_id': '', 'monitor': 'no-monitoring', 'namespace': 'tests', + 'onboard_packit': 'no', 'repo': 'foo', 'description': 'Some description', 'upstreamurl': ''