Fix branch_or_tag parse constraint, minor refactor. Refs #263

This commit is contained in:
Pavel Chipiga 2012-08-02 17:54:34 +03:00
parent dc95d6c13a
commit 33d722b779
1 changed files with 1 additions and 1 deletions

View File

@ -24,7 +24,7 @@ module Rosa
if (params = request.path_parameters) && params[:treeish] # parse existing branch (tag) and path
branch_or_tag = begin
(p = Project.find_by_owner_and_name params[:owner_name], params[:project_name]) &&
p.repo.branches_and_tags.detect{|t| params[:treeish].start_with?(t.name)}.try(:name) ||
p.repo.branches_and_tags.map(&:name).sort{|a,b| b.length <=> a.length}.detect{|b| params[:treeish].start_with?(b)} ||
params[:treeish].split('/').first
end
if path = params[:treeish].sub(branch_or_tag, '')[1..-1] and path.present?