Rename forked project to avoid conflict

Project will be renamed during the fork. New name & path template is
"centos_<namespace>_<project>" instead of <project>.

Signed-off-by: Ondrej Nosek <onosek@redhat.com>
This commit is contained in:
Ondrej Nosek 2021-03-30 22:37:48 +02:00
parent 80f38de2d6
commit 9a602e67b2
2 changed files with 10 additions and 3 deletions

View file

@ -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,
)

View file

@ -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,
)