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
bbf2ef06
Commit
bbf2ef06
authored
Aug 04, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ABC size of BlobController#show
parent
4c45f8ba
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
24 deletions
+32
-24
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+32
-24
No files found.
app/controllers/projects/blob_controller.rb
View file @
bbf2ef06
...
...
@@ -37,33 +37,11 @@ class Projects::BlobController < Projects::ApplicationController
respond_to
do
|
format
|
format
.
html
do
environment_params
=
@repository
.
branch_exists?
(
@ref
)
?
{
ref:
@ref
}
:
{
commit:
@commit
}
@environment
=
EnvironmentsFinder
.
new
(
@project
,
current_user
,
environment_params
).
execute
.
last
@last_commit
=
@repository
.
last_commit_for_path
(
@commit
.
id
,
@blob
.
path
)
render
'show'
show_html
end
format
.
json
do
json
=
blob_json
(
@blob
)
return
render_404
unless
json
render
json:
json
.
merge
(
path:
blob
.
path
,
name:
blob
.
name
,
extension:
blob
.
extension
,
size:
blob
.
raw_size
,
mime_type:
blob
.
mime_type
,
binary:
blob
.
raw_binary?
,
simple_viewer:
blob
.
simple_viewer
&
.
class
&
.
partial_name
,
rich_viewer:
blob
.
rich_viewer
&
.
class
&
.
partial_name
,
show_viewer_switcher:
!!
blob
.
show_viewer_switcher?
,
render_error:
blob
.
simple_viewer
&
.
render_error
||
blob
.
rich_viewer
&
.
render_error
,
raw_path:
project_raw_path
(
project
,
@id
),
blame_path:
project_blame_path
(
project
,
@id
),
commits_path:
project_commits_path
(
project
,
@id
),
permalink:
project_blob_path
(
project
,
File
.
join
(
@commit
.
id
,
@path
))
)
show_json
end
end
end
...
...
@@ -207,4 +185,34 @@ class Projects::BlobController < Projects::ApplicationController
@last_commit_sha
=
Gitlab
::
Git
::
Commit
.
last_for_path
(
@repository
,
@ref
,
@path
).
sha
end
def
show_html
environment_params
=
@repository
.
branch_exists?
(
@ref
)
?
{
ref:
@ref
}
:
{
commit:
@commit
}
@environment
=
EnvironmentsFinder
.
new
(
@project
,
current_user
,
environment_params
).
execute
.
last
@last_commit
=
@repository
.
last_commit_for_path
(
@commit
.
id
,
@blob
.
path
)
render
'show'
end
def
show_json
json
=
blob_json
(
@blob
)
return
render_404
unless
json
render
json:
json
.
merge
(
path:
blob
.
path
,
name:
blob
.
name
,
extension:
blob
.
extension
,
size:
blob
.
raw_size
,
mime_type:
blob
.
mime_type
,
binary:
blob
.
raw_binary?
,
simple_viewer:
blob
.
simple_viewer
&
.
class
&
.
partial_name
,
rich_viewer:
blob
.
rich_viewer
&
.
class
&
.
partial_name
,
show_viewer_switcher:
!!
blob
.
show_viewer_switcher?
,
render_error:
blob
.
simple_viewer
&
.
render_error
||
blob
.
rich_viewer
&
.
render_error
,
raw_path:
project_raw_path
(
project
,
@id
),
blame_path:
project_blame_path
(
project
,
@id
),
commits_path:
project_commits_path
(
project
,
@id
),
permalink:
project_blob_path
(
project
,
File
.
join
(
@commit
.
id
,
@path
))
)
end
end
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