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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
7f625f06
Commit
7f625f06
authored
Apr 13, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass project to Blob
parent
00e4ec55
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
5 deletions
+13
-5
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-1
app/models/blob.rb
app/models/blob.rb
+10
-2
app/models/commit.rb
app/models/commit.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+1
-1
No files found.
app/controllers/projects/blob_controller.rb
View file @
7f625f06
...
@@ -96,7 +96,7 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -96,7 +96,7 @@ class Projects::BlobController < Projects::ApplicationController
private
private
def
blob
def
blob
@blob
||=
Blob
.
decorate
(
@repository
.
blob_at
(
@commit
.
id
,
@path
))
@blob
||=
Blob
.
decorate
(
@repository
.
blob_at
(
@commit
.
id
,
@path
)
,
@project
)
if
@blob
if
@blob
@blob
@blob
...
...
app/models/blob.rb
View file @
7f625f06
...
@@ -6,6 +6,8 @@ class Blob < SimpleDelegator
...
@@ -6,6 +6,8 @@ class Blob < SimpleDelegator
# The maximum size of an SVG that can be displayed.
# The maximum size of an SVG that can be displayed.
MAXIMUM_SVG_SIZE
=
2
.
megabytes
MAXIMUM_SVG_SIZE
=
2
.
megabytes
attr_reader
:project
# Wrap a Gitlab::Git::Blob object, or return nil when given nil
# Wrap a Gitlab::Git::Blob object, or return nil when given nil
#
#
# This method prevents the decorated object from evaluating to "truthy" when
# This method prevents the decorated object from evaluating to "truthy" when
...
@@ -16,10 +18,16 @@ class Blob < SimpleDelegator
...
@@ -16,10 +18,16 @@ class Blob < SimpleDelegator
#
#
# blob = Blob.decorate(nil)
# blob = Blob.decorate(nil)
# puts "truthy" if blob # No output
# puts "truthy" if blob # No output
def
self
.
decorate
(
blob
)
def
self
.
decorate
(
blob
,
project
)
return
if
blob
.
nil?
return
if
blob
.
nil?
new
(
blob
)
new
(
blob
,
project
)
end
def
initialize
(
blob
,
project
)
@project
=
project
super
(
blob
)
end
end
# Returns the data of the blob.
# Returns the data of the blob.
...
...
app/models/commit.rb
View file @
7f625f06
...
@@ -316,7 +316,7 @@ class Commit
...
@@ -316,7 +316,7 @@ class Commit
def
uri_type
(
path
)
def
uri_type
(
path
)
entry
=
@raw
.
tree
.
path
(
path
)
entry
=
@raw
.
tree
.
path
(
path
)
if
entry
[
:type
]
==
:blob
if
entry
[
:type
]
==
:blob
blob
=
::
Blob
.
decorate
(
Gitlab
::
Git
::
Blob
.
new
(
name:
entry
[
:name
]))
blob
=
::
Blob
.
decorate
(
Gitlab
::
Git
::
Blob
.
new
(
name:
entry
[
:name
])
,
@project
)
blob
.
image?
||
blob
.
video?
?
:raw
:
:blob
blob
.
image?
||
blob
.
video?
?
:raw
:
:blob
else
else
entry
[
:type
]
entry
[
:type
]
...
...
app/models/repository.rb
View file @
7f625f06
...
@@ -450,7 +450,7 @@ class Repository
...
@@ -450,7 +450,7 @@ class Repository
def
blob_at
(
sha
,
path
)
def
blob_at
(
sha
,
path
)
unless
Gitlab
::
Git
.
blank_ref?
(
sha
)
unless
Gitlab
::
Git
.
blank_ref?
(
sha
)
Blob
.
decorate
(
Gitlab
::
Git
::
Blob
.
find
(
self
,
sha
,
path
))
Blob
.
decorate
(
Gitlab
::
Git
::
Blob
.
find
(
self
,
sha
,
path
)
,
project
)
end
end
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
nil
nil
...
...
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