Fix branch with dots. Refs #263

This commit is contained in:
Pavel Chipiga 2012-07-03 15:05:27 +03:00
parent 60b4f6a561
commit b46a7aba39
3 changed files with 31 additions and 28 deletions

View File

@ -179,31 +179,33 @@ Rosa::Application.routes.draw do
get '/sections' => 'projects#sections', :as => :sections_project get '/sections' => 'projects#sections', :as => :sections_project
post '/sections' => 'projects#sections' post '/sections' => 'projects#sections'
delete '/remove_user' => 'projects#remove_user', :as => :remove_user_project delete '/remove_user' => 'projects#remove_user', :as => :remove_user_project
# Tree constraints :treeish => /[^\/]+/ do
get '/' => "git/trees#show", :as => :project # Tree
get '/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree, :format => false get '/' => "git/trees#show", :as => :project
# Commits get '/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree, :format => false
get '/commits/:treeish(/*path)' => "git/commits#index", :defaults => {:treeish => :master}, :as => :commits, :format => false # Commits
get '/commit/:id(.:format)' => "git/commits#show", :as => :commit get '/commits/:treeish(/*path)' => "git/commits#index", :defaults => {:treeish => :master}, :as => :commits, :format => false
# Commit comments get '/commit/:id(.:format)' => "git/commits#show", :as => :commit
post '/commit/:commit_id/comments(.:format)' => "comments#create", :as => :project_commit_comments # Commit comments
get '/commit/:commit_id/comments/:id(.:format)' => "comments#edit", :as => :edit_project_commit_comment post '/commit/:commit_id/comments(.:format)' => "comments#create", :as => :project_commit_comments
put '/commit/:commit_id/comments/:id(.:format)' => "comments#update", :as => :project_commit_comment get '/commit/:commit_id/comments/:id(.:format)' => "comments#edit", :as => :edit_project_commit_comment
delete '/commit/:commit_id/comments/:id(.:format)' => "comments#destroy" put '/commit/:commit_id/comments/:id(.:format)' => "comments#update", :as => :project_commit_comment
# Commit subscribes delete '/commit/:commit_id/comments/:id(.:format)' => "comments#destroy"
post '/commit/:commit_id/subscribe' => "commit_subscribes#create", :as => :subscribe_commit # Commit subscribes
delete '/commit/:commit_id/unsubscribe' => "commit_subscribes#destroy", :as => :unsubscribe_commit post '/commit/:commit_id/subscribe' => "commit_subscribes#create", :as => :subscribe_commit
# Editing files delete '/commit/:commit_id/unsubscribe' => "commit_subscribes#destroy", :as => :unsubscribe_commit
get '/blob/:treeish/*path/edit' => "git/blobs#edit", :defaults => {:treeish => :master}, :as => :edit_blob # Editing files
put '/blob/:treeish/*path' => "git/blobs#update", :defaults => {:treeish => :master}, :format => false get '/blob/:treeish/*path/edit' => "git/blobs#edit", :defaults => {:treeish => :master}, :as => :edit_blob
# Blobs put '/blob/:treeish/*path' => "git/blobs#update", :defaults => {:treeish => :master}, :format => false
get '/blob/:treeish/*path' => "git/blobs#show", :defaults => {:treeish => :master}, :as => :blob, :format => false # Blobs
# Blame get '/blob/:treeish/*path' => "git/blobs#show", :defaults => {:treeish => :master}, :as => :blob, :format => false
get '/blame/:treeish/*path' => "git/blobs#blame", :defaults => {:treeish => :master}, :as => :blame, :format => false # Blame
# Raw get '/blame/:treeish/*path' => "git/blobs#blame", :defaults => {:treeish => :master}, :as => :blame, :format => false
get '/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false # Raw
# Archive get '/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false
get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/ # Archive
get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
end
end end
end end

View File

@ -304,7 +304,7 @@ ActiveRecord::Schema.define(:version => 20120628165702) do
t.integer "build_count", :default => 0, :null => false t.integer "build_count", :default => 0, :null => false
end end
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
create_table "register_requests", :force => true do |t| create_table "register_requests", :force => true do |t|
t.string "name" t.string "name"

View File

@ -36,8 +36,9 @@ describe Projects::Git::TreesController do
it "routes to #show" do it "routes to #show" do
get("/import/glib2.0-mib").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib') get("/import/glib2.0-mib").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib')
get("/import/glib2.0-mib/tree/branch").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'branch') get("/import/glib2.0-mib/tree/lib2safe-0.03").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'lib2safe-0.03')
get("/import/glib2.0-mib/tree/branch/some/path.to").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'branch', :path => 'some/path.to') get("/import/glib2.0-mib/tree/branch-with.dot/folder_with.dot/path-with.dot").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'branch-with.dot', :path => 'folder_with.dot/path-with.dot')
# get("/import/glib2.0-mib/tree/ветка-с.точкой/папка_с.точкой/путь-с.точкой").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'ветка-с.точкой', :path => 'папка_с.точкой/путь-с.точкой')
end end
# TODO write more specs also with slash in branch name! # TODO write more specs also with slash in branch name!