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
1e6d3f3a
Commit
1e6d3f3a
authored
Jan 25, 2022
by
Chad Woolley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Blob#symlink? boolean method
Changelog: added
parent
fa814c9e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
3 deletions
+22
-3
app/models/blob.rb
app/models/blob.rb
+4
-0
app/views/projects/blob/_header_content.html.haml
app/views/projects/blob/_header_content.html.haml
+1
-1
spec/models/blob_spec.rb
spec/models/blob_spec.rb
+14
-0
spec/support/helpers/fake_blob_helpers.rb
spec/support/helpers/fake_blob_helpers.rb
+3
-2
No files found.
app/models/blob.rb
View file @
1e6d3f3a
...
...
@@ -178,6 +178,10 @@ class Blob < SimpleDelegator
end
end
def
symlink?
mode
==
MODE_SYMLINK
end
def
extension
@extension
||=
extname
.
downcase
.
delete
(
'.'
)
end
...
...
app/views/projects/blob/_header_content.html.haml
View file @
1e6d3f3a
...
...
@@ -9,7 +9,7 @@
=
copy_file_path_button
(
blob
.
path
)
%small
.mr-1
-
if
blob
.
mode
==
Blob
::
MODE_SYMLINK
-
if
blob
.
symlink?
=
_
(
'Symbolic link'
)
<<
' ·'
=
number_to_human_size
(
blob
.
raw_size
)
...
...
spec/models/blob_spec.rb
View file @
1e6d3f3a
...
...
@@ -215,6 +215,20 @@ RSpec.describe Blob do
end
end
describe
'#symlink?'
do
it
'is true for symlinks'
do
symlink_blob
=
fake_blob
(
path:
'file'
,
mode:
'120000'
)
expect
(
symlink_blob
.
symlink?
).
to
eq
true
end
it
'is false for non-symlinks'
do
non_symlink_blob
=
fake_blob
(
path:
'file'
,
mode:
'100755'
)
expect
(
non_symlink_blob
.
symlink?
).
to
eq
false
end
end
describe
'#extension'
do
it
'returns the extension'
do
blob
=
fake_blob
(
path:
'file.md'
)
...
...
spec/support/helpers/fake_blob_helpers.rb
View file @
1e6d3f3a
...
...
@@ -4,13 +4,14 @@ module FakeBlobHelpers
class
FakeBlob
include
BlobLike
attr_reader
:path
,
:size
,
:data
,
:lfs_oid
,
:lfs_size
attr_reader
:path
,
:size
,
:data
,
:lfs_oid
,
:lfs_size
,
:mode
def
initialize
(
path:
'file.txt'
,
size:
1
.
kilobyte
,
data:
'foo'
,
binary:
false
,
lfs:
nil
)
def
initialize
(
path:
'file.txt'
,
size:
1
.
kilobyte
,
data:
'foo'
,
binary:
false
,
lfs:
nil
,
mode:
nil
)
@path
=
path
@size
=
size
@data
=
data
@binary
=
binary
@mode
=
mode
@lfs_pointer
=
lfs
.
present?
if
@lfs_pointer
...
...
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