From 934cb8fbb8e7c4a165887b666a8ec69ee357bab9 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 14 Feb 2013 12:55:47 +0600 Subject: [PATCH] [refs #907] fixed 404 in branch with dots --- app/controllers/projects/git/commits_controller.rb | 9 +++++---- config/routes.rb | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/projects/git/commits_controller.rb b/app/controllers/projects/git/commits_controller.rb index cc83b1bd7..080cefbe8 100644 --- a/app/controllers/projects/git/commits_controller.rb +++ b/app/controllers/projects/git/commits_controller.rb @@ -20,12 +20,13 @@ class Projects::Git::CommitsController < Projects::Git::BaseController end def diff - if params[:commit2].present? - params1 = params[:commit1] - params2 = params[:commit2] == 'HEAD' ? @project.default_branch : params[:commit2] + res = params[:diff].split(/\A(.*)\.\.\.(.*)\z/).select {|e| e.present?} + if res[1].present? + params1 = res[0] + params2 = res[1] == 'HEAD' ? @project.default_branch : res.last else # get only one parameter params1 = @project.default_branch - params2 = params[:commit1] + params2 = res.first end params1.sub! 'HEAD', @project.default_branch params2.sub! 'HEAD', @project.default_branch diff --git a/config/routes.rb b/config/routes.rb index e0c4f6446..73c70fa17 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -317,7 +317,7 @@ Rosa::Application.routes.draw do # Archive get '/archive/:treeish.:format' => "git/trees#archive", :as => :archive, :format => /zip|tar\.gz/ # Git diff - get '/diff/:commit1(...:commit2)' => "git/commits#diff", :as => :diff + get '/diff/:diff' => "git/commits#diff", :as => :diff, :format => false, :diff => /.*/ end end end