Merge pull request #595 from warpc/263-refactoring

Fix branch_or_tag parse constraint, minor refactor. Refs #263
This commit is contained in:
Vladimir Sharshov 2012-08-02 08:31:25 -07:00
commit c50ec09f36
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?