From 0da2d940d9ad1fef15092e3c261627d310ebb8f9 Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: May 06 2020 07:46:00 +0000 Subject: fedpkg fork adds correct remote URL Except the correct URL fixes the right function when the repo is in directory differs from the project name. And removes unnecessary `namespace` argument. JIRA: RHELCMP-438 Fixes: #394 Signed-off-by: Ondrej Nosek --- diff --git a/fedpkg/cli.py b/fedpkg/cli.py index 0817306..3384d8e 100644 --- a/fedpkg/cli.py +++ b/fedpkg/cli.py @@ -471,13 +471,6 @@ class fedpkgClient(cliClient): formatter_class=argparse.RawDescriptionHelpFormatter, help=help_msg, description=description) - fork_parser.add_argument( - '--namespace', - required=False, - default='rpms', - choices=self.get_distgit_namespaces(), - dest='fork_namespace', - help='Namespace of the fork. If omitted, default to rpms.') fork_parser.set_defaults(command=self.do_distgit_fork) def register_releases_info(self): @@ -1107,7 +1100,7 @@ class fedpkgClient(cliClient): distgit_remote_base_url = self.config.get( '{0}'.format(self.name), "gitbaseurl", - vars={'user': 'any', 'repo': 'any'}, + vars={'user': self.cmd.user, 'repo': self.cmd.repo_name}, ) distgit_token = config_get_safely(self.config, distgit_section, 'token') @@ -1117,7 +1110,8 @@ class fedpkgClient(cliClient): token=distgit_token, username=self.cmd.user, repo=self.cmd.repo, - namespace=self.args.fork_namespace, + repo_name=self.cmd.repo_name, + namespace=self.cmd.ns, cli_name=self.name, ) if fork_url: diff --git a/fedpkg/utils.py b/fedpkg/utils.py index b639c4f..8848895 100644 --- a/fedpkg/utils.py +++ b/fedpkg/utils.py @@ -11,7 +11,6 @@ # the full text of the license. import json -import os import re from datetime import datetime @@ -136,7 +135,8 @@ def new_pagure_issue(url, token, title, body, cli_name): url.rstrip('/'), rv.json()['issue']['id']) -def do_fork(base_url, remote_base_url, token, username, repo, namespace, cli_name): +def do_fork(base_url, remote_base_url, token, username, repo, repo_name, + namespace, cli_name): """ Creates a fork of the project. :param base_url: a string of the URL repository @@ -144,6 +144,7 @@ def do_fork(base_url, remote_base_url, token, username, repo, namespace, cli_nam :param token: a string of the API token that has rights to make a fork :param username: a string of the (FAS) user name :param repo: object, current project git repository + :param repo_name: a string of the repository name :param namespace: a string determines a type of the repository :param cli_name: string of the CLI's name (e.g. fedpkg) :return: a string of the URL to the created fork in the UI @@ -151,8 +152,6 @@ def do_fork(base_url, remote_base_url, token, username, repo, namespace, cli_nam api_url = '{0}/api/0'.format(base_url.rstrip('/')) fork_url = '{0}/fork'.format(api_url) - repo_name = os.path.basename(repo.working_dir) - parsed_url = urlparse(remote_base_url) remote_url = '{0}://{1}/forks/{2}/{3}/{4}.git'.format( parsed_url.scheme, @@ -202,8 +201,9 @@ def do_fork(base_url, remote_base_url, token, username, repo, namespace, cli_nam " ".join(e.command), e.stderr) raise rpkgError(error_msg) - return '{0}/fork/{1}/{2}'.format( - base_url.rstrip('/'), username, repo_name) + # create and return url of the repo in web browser + return '{0}/fork/{1}/{2}/{3}'.format( + base_url.rstrip('/'), username, namespace, repo_name) def get_release_branches(server_url):