Skip to content

Commit

Permalink
[api] fix multiple running release requests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Nov 18, 2011
1 parent b701b9f commit 91b775d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/api/app/controllers/request_controller.rb
Expand Up @@ -560,10 +560,21 @@ def create_create
end
end
end

# check for open release requests with same target, the binaries can't get merged automatically
# either exact target package match or with same prefix (when using the incident extension)
tpkgprefix=action.target.package.gsub(/\..*/, '')
predicate = "(state/@name='new' or state/@name='review') and action/target/@project='#{action.target.project}' and (action/target/@package='#{action.target.package}' or starts-with(action/target/@package,'#{tpkgprefix}.'))"

# patchinfos don't get a link, all others should not conflict with any other
answer = Suse::Backend.get "/source/#{CGI.escape(action.source.project)}/#{CGI.escape(action.source.package)}"
xml = REXML::Document.new(answer.body.to_s)
if xml.elements["/directory/entry/@name='_patchinfo'"]
predicate = "(state/@name='new' or state/@name='review') and action/target/@project='#{action.target.project}' and action/target/@package='#{action.target.package}'"
else
tpkgprefix = action.target.package.gsub(/\..*/, '')
predicate = "(state/@name='new' or state/@name='review') and action/target/@project='#{action.target.project}' and (action/target/@package='#{action.target.package}' or starts-with(action/target/@package,'#{tpkgprefix}.'))"
end

# run search
collection = Suse::Backend.post("/search/request?match=#{CGI.escape(predicate)}", nil).body
rqs = collection.scan(/request id\="(\d+)"/).flatten
if rqs.size > 0
Expand Down

0 comments on commit 91b775d

Please sign in to comment.