Skip to content

Commit

Permalink
Allow a package maintainer to rebuild packages
Browse files Browse the repository at this point in the history
  • Loading branch information
vpereira committed Dec 12, 2019
1 parent 62e1e3c commit 0c7e4fd
Show file tree
Hide file tree
Showing 7 changed files with 387 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,9 @@ def abort_build
def trigger_rebuild
authorize @package, :update?

if @package.rebuild(params)
allowed_params = [:project, :package, :repository, :arch]

if @package.rebuild(params.slice(*allowed_params).permit!.to_h)
flash[:success] = "Triggered rebuild for #{@project.name}/#{@package.name} successfully."
redirect_to package_show_path(project: @project, package: @package)
else
Expand Down
10 changes: 9 additions & 1 deletion src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require_dependency 'opensuse/validator'
require_dependency 'authenticator'

# rubocop: disable Metrics/ClassLength
class Package < ApplicationRecord
include FlagHelper
include Flag::Validations
Expand Down Expand Up @@ -1380,7 +1381,13 @@ def fixtures_name

#### WARNING: these operations run in build object, not this package object
def rebuild(params)
backend_build_command(:rebuild, params[:project], params.slice(:package, :arch, :repository))
begin
Backend::Api::Sources::Package.rebuild(params[:project], params[:package], params)
rescue Backend::Error, Timeout::Error, Project::WritePermissionError => e
errors.add(:base, e.message)
return false
end
true
end

def wipe_binaries(params)
Expand Down Expand Up @@ -1489,6 +1496,7 @@ def fetch_rev_from_history_cache(rev)
Rails.cache.read(['history', self, rev]) || Rails.cache.read(['history_md5', self, rev])
end
end
# rubocop: enable Metrics/ClassLength

# == Schema Information
#
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0c7e4fd

Please sign in to comment.