Skip to content

Commit

Permalink
[api] fix regression and long standing bug on remote project handling
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Jan 11, 2012
1 parent 95e91d1 commit 9ebee1c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/api/app/controllers/source_controller.rb
Expand Up @@ -1317,14 +1317,16 @@ def do_branch
end
else
pkg = DbPackage.get_by_project_and_name params[:project], params[:package]
prj = pkg.db_project if pkg and not prj.find_attribute("OBS", "BranchTarget")
unless prj.class == DbProject and prj.find_attribute("OBS", "BranchTarget")
prj = pkg.db_project if pkg
end
end
tpkg_name = params[:target_package]
tpkg_name = params[:package] unless tpkg_name
tpkg_name += ".#{params[:project]}" if extend_names
if pkg
# local package
@packages.push({ :base_project => prj, :link_target_project => pkg.db_project, :package => pkg, :rev => params[:rev], :target_package => tpkg_name })
@packages.push({ :base_project => prj, :link_target_project => prj, :package => pkg, :rev => params[:rev], :target_package => tpkg_name })
else
# remote or not existing package
@packages.push({ :base_project => prj, :link_target_project => (prj||params[:project]), :package => params[:package], :rev => params[:rev], :target_package => tpkg_name })
Expand Down
3 changes: 2 additions & 1 deletion src/api/app/models/db_project.rb
Expand Up @@ -228,7 +228,8 @@ def securedfind_initial(options)
def get_by_name(name)
dbp = find :first, :conditions => ["name = BINARY ?", name]
if dbp.nil?
return dbp if dbp = find_remote_project(name)
dbp, remote_name = find_remote_project(name)
return dbp.name + ":" + remote_name if dbp
raise UnknownObjectError, name
end
unless check_access?(dbp)
Expand Down
4 changes: 2 additions & 2 deletions src/api/test/functional/attributes_test.rb
Expand Up @@ -30,7 +30,7 @@ def test_namespace_index

get "/attribute/OBS"
assert_response :success
count = 9
count = 10
assert_tag :tag => 'directory', :attributes => { :count => count }
assert_tag :children => { :count => count }
assert_tag :child => { :tag => 'entry', :attributes => { :name => "Maintained" } }
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_attrib_type_meta

get "/attribute/OBS"
assert_response :success
count = 9
count = 10
assert_tag :tag => 'directory', :attributes => { :count => count }
assert_tag :children => { :count => count }
assert_tag :child => { :tag => 'entry', :attributes => { :name => "Maintained" } }
Expand Down

0 comments on commit 9ebee1c

Please sign in to comment.