Skip to content

Commit de71095

Browse files
committed
Add '--gitea-fork-org' option to 'osc fork' command
1 parent 02b342a commit de71095

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

behave/features/fork.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,30 @@ Feature: `osc fork` command
44
Background:
55
Given I set working directory to "{context.osc.temp}"
66

7+
78
@destructive
89
Scenario: Fork a git repo
910
When I execute osc with args "fork test:factory test-GitPkgA"
1011
Then the exit code is 0
1112
And stdout contains " scmsync URL: "
1213
And stdout contains "/Admin/test-GitPkgA#factory"
14+
15+
16+
@destructive
17+
Scenario: Fork multiple git repos from different orgs
18+
When I execute git-obs with args "-G admin api -X POST /orgs --data '{{"username": "devel"}}'"
19+
When I execute osc with args "fork test:factory test-GitPkgA --target-project=test:devel --no-devel-project --gitea-fork-org=devel"
20+
Then the exit code is 0
21+
And stdout contains " scmsync URL: "
22+
And stdout contains "/devel/test-GitPkgA#factory"
23+
When I execute osc with args "fork test:factory test-GitPkgA --target-project=home:Admin --no-devel-project"
24+
Then the exit code is 0
25+
And stdout contains " scmsync URL: "
26+
And stdout contains "/Admin/test-GitPkgA#factory"
27+
When I execute osc with args "fork test:devel test-GitPkgA --target-project=home:Admin --no-devel-project"
28+
# there's an existing fork from a different org, the command fails
29+
Then the exit code is 1
30+
When I execute osc with args "fork test:devel test-GitPkgA --target-project=home:Admin --new-repo-name="test-GitPkgA-devel" --no-devel-project"
31+
Then the exit code is 0
32+
And stdout contains " scmsync URL: "
33+
And stdout contains "/Admin/test-GitPkgA-devel#factory"

osc/commands/fork.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ def init_arguments(self):
5151
help="Name of the package (defaults to $package)",
5252
)
5353

54+
self.add_argument(
55+
"--gitea-fork-org",
56+
help="Name of the org owning the fork",
57+
)
58+
5459
self.add_argument_new_repo_name()
5560

5661
self.add_argument(
@@ -155,7 +160,7 @@ def run(self, args):
155160
parent_branch_obj = gitea_api.Branch.get(gitea_conn, owner, repo, fork_branch)
156161

157162
try:
158-
repo_obj = gitea_api.Fork.create(gitea_conn, owner, repo, new_repo_name=args.new_repo_name)
163+
repo_obj = gitea_api.Fork.create(gitea_conn, owner, repo, new_repo_name=args.new_repo_name, target_org=args.gitea_fork_org)
159164
fork_owner = repo_obj.owner
160165
fork_repo = repo_obj.repo
161166
print(f" * Fork created: {fork_owner}/{fork_repo}")

0 commit comments

Comments
 (0)