From 9a602e67b2f1808d4174b5c0105441e67926a63f Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Mar 30 2021 20:37:48 +0000 Subject: Rename forked project to avoid conflict Project will be renamed during the fork. New name & path template is "centos__" instead of . Signed-off-by: Ondrej Nosek --- diff --git a/src/centpkg/cli.py b/src/centpkg/cli.py index 798ba11..61e3147 100755 --- a/src/centpkg/cli.py +++ b/src/centpkg/cli.py @@ -89,9 +89,10 @@ class centpkgClient(cliClient): ) # assemble url of the repo in web browser - fork_url = '{0}/{1}/{2}'.format( + fork_url = '{0}/{1}/centos_{2}_{3}'.format( distgit_api_base_url.rstrip('/'), self.cmd.user, + self.cmd.ns, self.cmd.repo_name, ) diff --git a/src/centpkg/utils.py b/src/centpkg/utils.py index 634e8bb..4da4f78 100644 --- a/src/centpkg/utils.py +++ b/src/centpkg/utils.py @@ -40,7 +40,12 @@ def do_fork(logger, base_url, token, repo_name, namespace, cli_name): 'Accept': 'application/json', 'Content-Type': 'application/json' } - payload = json.dumps({}) + # define a new repository name/path to avoid collision with other projects + safe_name = "centos_{0}_{1}".format(namespace, repo_name) + payload = json.dumps({ + 'name': safe_name, # name of the project after forking + 'path': safe_name, + }) try: rv = requests.post( fork_url, headers=headers, data=payload, timeout=60) @@ -84,10 +89,11 @@ def do_add_remote(base_url, remote_base_url, username, repo, repo_name, :return: a bool; True if remote was created, False when already exists """ parsed_url = urlparse(remote_base_url) - remote_url = '{0}://{1}/{2}/{3}.git'.format( + remote_url = '{0}://{1}/{2}/centos_{3}_{4}.git'.format( parsed_url.scheme, parsed_url.netloc, username, + namespace, repo_name, )