From 33d722b77998d9cdbcf72b1f9be2863f8b09d297 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 2 Aug 2012 17:54:34 +0300 Subject: [PATCH] Fix branch_or_tag parse constraint, minor refactor. Refs #263 --- lib/ext/rosa/constraints.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ext/rosa/constraints.rb b/lib/ext/rosa/constraints.rb index fd7f45fbf..df007e540 100644 --- a/lib/ext/rosa/constraints.rb +++ b/lib/ext/rosa/constraints.rb @@ -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?