Skip to content

Commit

Permalink
[api] fix package meta data on project move and improve meta history
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Jun 24, 2015
1 parent e4b4979 commit da198a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/api/app/controllers/source_controller.rb
Expand Up @@ -1114,6 +1114,12 @@ class ProjectCopyNoPermission < APIException
def project_command_move
project_name = params[:oproject]

commit = { :login => User.current.login,
:lowprio => 1,
:comment => "Project move from #{params[:oproject]} to #{params[:project]}"
}
commit[:comment] = params[:comment] unless params[:comment].blank?

unless User.current.is_admin?
raise CmdExecutionNoPermission.new "Admin permissions required. STOP SCHEDULER BEFORE."
end
Expand All @@ -1126,7 +1132,9 @@ def project_command_move
project.name = params[:project]

Suse::Backend.post "/source/#{URI.escape(project.name)}?cmd=move&oproject=#{CGI.escape(project_name)}", nil
project.store
project.store(commit)
# update meta data in all packages, they contain the project name as well
project.packages.each {|p| p.store(commit)}
rescue
render_error :status => 400, :errorcode => 'move_failed',
:message => 'Move operation failed'
Expand Down
12 changes: 11 additions & 1 deletion src/api/test/functional/release_management_test.rb
Expand Up @@ -25,8 +25,12 @@ def test_move_entire_project
assert_response :success
get "/source/TEMP:BaseDistro/_project"
assert_response :success
get "/source/TEMP:BaseDistro/pack2"
get "/source/TEMP:BaseDistro/_project/_history?meta=1"
assert_response :success
assert_xml_tag :tag => "comment", :content => "Project move from BaseDistro to TEMP:BaseDistro"
get "/source/TEMP:BaseDistro/pack2/_meta"
assert_response :success
assert_xml_tag :tag => "package", :attributes => { :project => "TEMP:BaseDistro" }
get "/build/TEMP:BaseDistro"
assert_response :success
get "/build/TEMP:BaseDistro/BaseDistro_repo/i586/pack2/package-1.0-1.i586.rpm"
Expand All @@ -42,6 +46,12 @@ def test_move_entire_project
post "/source/BaseDistro", :cmd => :move, :oproject => "TEMP:BaseDistro"
assert_response :success
assert_xml_tag( :tag => "status", :attributes => { :code => "ok"} )
get "/source/BaseDistro/pack2/_meta"
assert_response :success
assert_xml_tag :tag => "package", :attributes => { :project => "BaseDistro" }
get "/source/BaseDistro/_project/_history?meta=1"
assert_response :success
assert_xml_tag :tag => "comment", :content => "Project move from TEMP:BaseDistro to BaseDistro"
get "/build/TEMP:BaseDistro"
assert_response 404
get "/build/TEMP:BaseDistro/BaseDistro_repo/i586/pack2/package-1.0-1.i586.rpm"
Expand Down

0 comments on commit da198a9

Please sign in to comment.