Redirect commits to root_ref if no ref is provided

This commit is contained in:
Kia Mei Somabes 2018-07-20 16:13:29 +08:00
parent 0ed8f3490e
commit 11d56a1551
3 changed files with 10 additions and 0 deletions

View File

@ -63,6 +63,10 @@ class ApplicationController < ActionController::Base
render_503
end
def redirect_commits_root
redirect_to :controller => 'commits', :action => 'show', :id => @repository.root_ref
end
def redirect_back_or_default(default: root_path, options: {})
redirect_to request.referer.present? ? :back : default, options
end

View File

@ -0,0 +1,5 @@
---
title: Redirect commits to root if no ref is provided (31576)
merge_request:
author: Kia Mei Somabes
type: added

View File

@ -83,6 +83,7 @@ scope format: false do
get '/raw/*id', to: 'raw#show', as: :raw
get '/blame/*id', to: 'blame#show', as: :blame
get '/commits/', to: 'application#redirect_commits_root', as: :commits_root
get '/commits/*id/signatures', to: 'commits#signatures', as: :signatures
get '/commits/*id', to: 'commits#show', as: :commits