Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
c03bc268
Commit
c03bc268
authored
Jul 24, 2018
by
Kia Mei Somabes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transfer to commits_controller, add test, and update changelog
parent
3b4734ce
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
9 deletions
+23
-9
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+0
-4
app/controllers/projects/commits_controller.rb
app/controllers/projects/commits_controller.rb
+7
-3
changelogs/unreleased/31576-redirect-commits-to-root-if-no-ref.yml
...s/unreleased/31576-redirect-commits-to-root-if-no-ref.yml
+1
-1
config/routes/repository.rb
config/routes/repository.rb
+1
-1
spec/controllers/projects/commits_controller_spec.rb
spec/controllers/projects/commits_controller_spec.rb
+14
-0
No files found.
app/controllers/application_controller.rb
View file @
c03bc268
...
...
@@ -63,10 +63,6 @@ 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
...
...
app/controllers/projects/commits_controller.rb
View file @
c03bc268
...
...
@@ -4,13 +4,17 @@ class Projects::CommitsController < Projects::ApplicationController
include
ExtractsPath
include
RendersCommits
before_action
:whitelist_query_limiting
before_action
:whitelist_query_limiting
,
except: :commits_root
before_action
:require_non_empty_project
before_action
:assign_ref_vars
before_action
:assign_ref_vars
,
except: :commits_root
before_action
:authorize_download_code!
before_action
:set_commits
before_action
:set_commits
,
except: :commits_root
before_action
:set_request_format
,
only: :show
def
commits_root
redirect_to
project_commits_path
(
@project
,
@project
.
default_branch
)
end
def
show
@merge_request
=
MergeRequestsFinder
.
new
(
current_user
,
project_id:
@project
.
id
).
execute
.
opened
.
find_by
(
source_project:
@project
,
source_branch:
@ref
,
target_branch:
@repository
.
root_ref
)
...
...
changelogs/unreleased/31576-redirect-commits-to-root-if-no-ref.yml
View file @
c03bc268
---
title
:
Redirect commits to root if no ref is provided (31576)
merge_request
:
merge_request
:
20738
author
:
Kia Mei Somabes
type
:
added
config/routes/repository.rb
View file @
c03bc268
...
...
@@ -83,7 +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
'
,
to:
'commits#
commits_root'
,
as: :commits_root
get
'/commits/*id/signatures'
,
to:
'commits#signatures'
,
as: :signatures
get
'/commits/*id'
,
to:
'commits#show'
,
as: :commits
...
...
spec/controllers/projects/commits_controller_spec.rb
View file @
c03bc268
...
...
@@ -9,6 +9,20 @@ describe Projects::CommitsController do
project
.
add_master
(
user
)
end
describe
"GET commits_root"
do
context
"no ref is provided"
do
before
do
get
(
:commits_root
,
namespace_id:
project
.
namespace
,
project_id:
project
)
end
it
'should redirect to the default branch of the project'
do
expect
(
response
).
to
redirect_to
project_commits_path
(
project
)
end
end
end
describe
"GET show"
do
render_views
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment