1
0
mirror of https://github.com/openSUSE/osc.git synced 2026-01-11 01:07:04 +01:00

Merge pull request #1980 from danigm/fork-git-branch

fork: Add --git-branch optional argument
This commit is contained in:
2025-11-04 13:22:50 +01:00
committed by GitHub

View File

@@ -58,6 +58,11 @@ class ForkCommand(osc.commandline.OscCommand):
self.add_argument_new_repo_name()
self.add_argument(
"--git-branch",
help="Name of the new git branch",
)
self.add_argument(
"--no-devel-project",
action="store_true",
@@ -174,6 +179,17 @@ class ForkCommand(osc.commandline.OscCommand):
print(f" * You may also want to delete '{e.owner}/{e.repo}' and retry")
sys.exit(1)
# Crete the new branch if specified
if args.git_branch:
old_ref_name = fork_branch
fork_branch = args.git_branch
try:
parent_branch_obj = gitea_api.Branch.create(
gitea_conn, fork_owner, fork_repo, old_ref_name=old_ref_name, new_branch_name=fork_branch
)
except gitea_api.BranchExists:
print(f" * Branch already exists: {fork_branch}")
# XXX: implicit branch name should be forbidden; assumptions are bad
fork_scmsync = urllib.parse.urlunparse(
(parsed_scmsync_url.scheme, parsed_scmsync_url.netloc, f"{fork_owner}/{fork_repo}", "", parsed_scmsync_url.query, fork_branch)