Skip to content

Commit

Permalink
Merge pull request #6354 from hennevogel/bugfix/staging-workflow
Browse files Browse the repository at this point in the history
Bugfix staging workflow
  • Loading branch information
ChrisBr committed Nov 22, 2018
2 parents 78dc408 + 26abbfb commit 91160be
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/api/api/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1932,13 +1932,15 @@ XmlResult: required_checks


== Staging
WARNING: This API is currently in beta and unstable

=== Excluded Requests

<project>: The name of the main project of a Staging, e.g. openSUSE_Tumbleweed
<request>: The number of the request, e.g. 12345
<description>: A string of text (url encoded)

POST /staging_excluded_requests/<request>/<project>
POST /staging_excluded_requests/<request>/<project>?description=<description>
Exclude this request from this Staging

DELETE /staging_excluded_requests/<request>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create
result = ::Staging::StageRequests.new(
request_numbers: request_numbers,
staging_workflow: @staging_workflow,
staging_project_name: @staging_project.name
staging_project: @staging_project
).perform

if result.valid?
Expand Down
7 changes: 4 additions & 3 deletions src/api/app/models/staging/stage_requests.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Staging::StageRequests
include ActiveModel::Model
attr_accessor :request_numbers, :staging_project_name, :staging_workflow
attr_accessor :request_numbers, :staging_project, :staging_workflow

def perform
add_request_not_found_errors
Expand Down Expand Up @@ -50,17 +50,18 @@ def requests
def branch_package(bs_request_action)
request = bs_request_action.bs_request
BranchPackage.new(
target_project: staging_project_name,
target_project: staging_project.name,
target_package: bs_request_action.target_package,
project: bs_request_action.source_project,
package: bs_request_action.source_package,
extend_package_names: false
).branch
staging_project.staged_requests << request
result << request
rescue BranchPackage::DoubleBranchPackageError
# we leave the package there and do not report as success
# because packages might differ
errors << "Request '#{request.number}' already branched into '#{staging_project_name}'"
errors << "Request '#{request.number}' already branched into '#{staging_project.name}'"
rescue APIError, Backend::Error => e
errors << "Request '#{request.number}' branching failed: '#{e.message}'"
Airbrake.notify(e, bs_request: request.number)
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/policies/staging/workflow_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def initialize(user, record)
end

def create?
ProjectPolicy.new(@user, @record.project).create?
ProjectPolicy.new(@user, @record.project).update?
end

def update?
Expand Down

0 comments on commit 91160be

Please sign in to comment.