mirror of
https://github.com/openSUSE/osc.git
synced 2026-03-08 01:56:15 +01:00
Fix working with labels in 'git-obs staging group'
This commit is contained in:
@@ -32,12 +32,16 @@ Background:
|
||||
Scenario: Scenario 1: staging group --no-ssh-strict-host-key-checking with --target and existing PR
|
||||
When I execute git-obs with args "-G alice staging group --no-ssh-strict-host-key-checking --target=pool/test-GitPkgA#1 pool/test-GitPkgA#2"
|
||||
Then the exit code is 0
|
||||
And stdout contains "Unable to add the 'staging/In Progress' label to pull request pool/test-GitPkgA#2"
|
||||
And stdout contains "Unable to remove the 'staging/Backlog' label from pull request pool/test-GitPkgA#2"
|
||||
And I execute git-obs with args "-G alice pr get pool/test-GitPkgA#1"
|
||||
Then the exit code is 0
|
||||
And stdout contains "State : open"
|
||||
And stdout contains "Description : PR: foo/bar!1"
|
||||
# It should also contain the reference from #2
|
||||
And stdout contains "PR: foo/bar!2"
|
||||
And stdout doesn't contain "staging/In Progress"
|
||||
And stdout contains "staging/Backlog"
|
||||
And I execute git-obs with args "-G alice pr get pool/test-GitPkgA#2"
|
||||
Then the exit code is 0
|
||||
And stdout contains "State : closed"
|
||||
@@ -47,6 +51,13 @@ Scenario: Scenario 1: staging group --no-ssh-strict-host-key-checking with --tar
|
||||
Scenario: Scenario 2: staging group --no-ssh-strict-host-key-checking with --target and --remove-pr-references
|
||||
When I execute git-obs with args "-G alice staging group --no-ssh-strict-host-key-checking --target=pool/test-GitPkgA#1 pool/test-GitPkgA#2 --remove-pr-references"
|
||||
Then the exit code is 0
|
||||
And stdout contains "Unable to add the 'staging/In Progress' label to pull request pool/test-GitPkgA#2"
|
||||
And stdout contains "Unable to remove the 'staging/Backlog' label from pull request pool/test-GitPkgA#2"
|
||||
And I execute git-obs with args "-G alice pr get pool/test-GitPkgA#1"
|
||||
Then the exit code is 0
|
||||
And stdout contains "State : open"
|
||||
And stdout doesn't contain "staging/In Progress"
|
||||
And stdout contains "staging/Backlog"
|
||||
And I execute git-obs with args "-G alice pr get pool/test-GitPkgA#2"
|
||||
Then the exit code is 0
|
||||
And stdout contains "State : closed"
|
||||
@@ -61,6 +72,8 @@ Scenario: Scenario 3: staging group --no-ssh-strict-host-key-checking without --
|
||||
And stdout contains "State : open"
|
||||
And stdout contains "PR: foo/bar!1"
|
||||
And stdout contains "PR: foo/bar!2"
|
||||
And stdout contains "Labels : staging/In Progress"
|
||||
And stdout doesn't contain "staging/Backlog"
|
||||
And I execute git-obs with args "-G alice pr get pool/test-GitPkgA#1"
|
||||
Then the exit code is 0
|
||||
# PR #1 should be closed because it was merged into #3
|
||||
@@ -78,6 +91,8 @@ Scenario: Scenario 4: staging group --no-ssh-strict-host-key-checking without --
|
||||
Then the exit code is 0
|
||||
And stdout contains "PR: foo/bar!1"
|
||||
And stdout contains "PR: foo/bar!2"
|
||||
And stdout contains "Labels : staging/In Progress"
|
||||
And stdout doesn't contain "staging/Backlog"
|
||||
And I execute git-obs with args "-G alice pr get pool/test-GitPkgA#1"
|
||||
Then the exit code is 0
|
||||
And stdout contains "State : closed"
|
||||
@@ -104,6 +119,8 @@ Scenario: Scenario 5: staging group --no-ssh-strict-host-key-checking by another
|
||||
And stdout contains "Author : Bob \(bob@example.com\)"
|
||||
And stdout contains "PR: foo/bar!1"
|
||||
And stdout contains "PR: foo/bar!2"
|
||||
And stdout contains "Labels : staging/In Progress"
|
||||
And stdout doesn't contain "staging/Backlog"
|
||||
|
||||
@destructive
|
||||
Scenario: Scenario 6: staging group --no-ssh-strict-host-key-checking by another user with push permissions to the target repository
|
||||
@@ -125,3 +142,5 @@ Scenario: Scenario 6: staging group --no-ssh-strict-host-key-checking by another
|
||||
And stdout contains "Source : pool/test-GitPkgA"
|
||||
And stdout contains "PR: foo/bar!1"
|
||||
And stdout contains "PR: foo/bar!2"
|
||||
And stdout contains "Labels : staging/In Progress"
|
||||
And stdout doesn't contain "staging/Backlog"
|
||||
|
||||
@@ -151,6 +151,30 @@ class StagingGroupCommand(osc.commandline_git.GitObsCommand):
|
||||
allow_maintainer_edit=True,
|
||||
)
|
||||
|
||||
# update labels
|
||||
try:
|
||||
gitea_api.PullRequest.add_labels(
|
||||
self.gitea_conn,
|
||||
target_pr_obj.base_owner,
|
||||
target_pr_obj.base_repo,
|
||||
int(target_pr_obj.number),
|
||||
labels=[gitea_api.StagingPullRequestWrapper.INPROGRESS_LABEL],
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Unable to add the '{gitea_api.StagingPullRequestWrapper.INPROGRESS_LABEL}' label to pull request {pr_obj.id}: {e}")
|
||||
|
||||
try:
|
||||
if gitea_api.StagingPullRequestWrapper.BACKLOG_LABEL in target_pr_obj.labels:
|
||||
gitea_api.PullRequest.remove_labels(
|
||||
self.gitea_conn,
|
||||
target_pr_obj.base_owner,
|
||||
target_pr_obj.base_repo,
|
||||
int(target_pr_obj.number),
|
||||
labels=[gitea_api.StagingPullRequestWrapper.BACKLOG_LABEL],
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Unable to remove the '{gitea_api.StagingPullRequestWrapper.BACKLOG_LABEL}' label from pull request {pr_obj.id}: {e}")
|
||||
|
||||
else:
|
||||
has_push_access = False
|
||||
if not args.fork_owner:
|
||||
|
||||
Reference in New Issue
Block a user