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
548cfd8b
Commit
548cfd8b
authored
Mar 09, 2020
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default to generating blob links for missing paths
parent
7ee66c95
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
6 deletions
+17
-6
changelogs/unreleased/25995-default-relative-links-to-blobs.yml
...logs/unreleased/25995-default-relative-links-to-blobs.yml
+5
-0
lib/banzai/filter/repository_link_filter.rb
lib/banzai/filter/repository_link_filter.rb
+4
-4
spec/helpers/markup_helper_spec.rb
spec/helpers/markup_helper_spec.rb
+1
-1
spec/lib/banzai/filter/repository_link_filter_spec.rb
spec/lib/banzai/filter/repository_link_filter_spec.rb
+7
-1
No files found.
changelogs/unreleased/25995-default-relative-links-to-blobs.yml
0 → 100644
View file @
548cfd8b
---
title
:
Default to generating blob links for missing paths
merge_request
:
26817
author
:
type
:
fixed
lib/banzai/filter/repository_link_filter.rb
View file @
548cfd8b
...
...
@@ -131,7 +131,7 @@ module Banzai
path
=
cleaned_file_path
(
uri
)
nested_path
=
relative_file_path
(
uri
)
file
_exists?
(
nested_path
)
?
nested_path
:
path
path
_exists?
(
nested_path
)
?
nested_path
:
path
end
def
cleaned_file_path
(
uri
)
...
...
@@ -190,12 +190,12 @@ module Banzai
parts
.
push
(
path
).
join
(
'/'
)
end
def
file
_exists?
(
path
)
path
.
present?
&&
uri_type
(
path
).
present?
def
path
_exists?
(
path
)
path
.
present?
&&
@uri_types
[
path
]
!=
:unknown
end
def
uri_type
(
path
)
@uri_types
[
path
]
==
:unknown
?
""
:
@uri_types
[
path
]
@uri_types
[
path
]
==
:unknown
?
:blob
:
@uri_types
[
path
]
end
def
current_commit
...
...
spec/helpers/markup_helper_spec.rb
View file @
548cfd8b
...
...
@@ -114,7 +114,7 @@ describe MarkupHelper do
let
(
:requested_path
)
{
nil
}
it
'returns the link to the image path as a relative path'
do
expanded_path
=
"/
#{
project
.
full_path
}
/master/./
#{
image_file
}
"
expanded_path
=
"/
#{
project
.
full_path
}
/
-/blob/
master/./
#{
image_file
}
"
expect
(
subject
.
css
(
'a'
)[
0
].
attr
(
'href'
)).
to
eq
(
expanded_path
)
end
...
...
spec/lib/banzai/filter/repository_link_filter_spec.rb
View file @
548cfd8b
...
...
@@ -145,7 +145,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
it
'ignores ref if commit is passed'
do
doc
=
filter
(
link
(
'non/existent.file'
),
commit:
project
.
commit
(
'empty-branch'
)
)
expect
(
doc
.
at_css
(
'a'
)[
'href'
])
.
to
eq
"/
#{
project_path
}
/
#{
ref
}
/non/existent.file"
# non-existent files have no leading blob/raw/tree
.
to
eq
"/
#{
project_path
}
/
-/blob/
#{
ref
}
/non/existent.file"
end
shared_examples
:valid_repository
do
...
...
@@ -201,6 +201,12 @@ describe Banzai::Filter::RepositoryLinkFilter do
.
to
eq
"/
#{
project_path
}
/-/blob/
#{
ref
}
/doc/api/README.md"
end
it
'rebuilds relative URL for a missing file in the repo'
do
doc
=
filter
(
link
(
'missing-file'
))
expect
(
doc
.
at_css
(
'a'
)[
'href'
])
.
to
eq
"/
#{
project_path
}
/-/blob/
#{
ref
}
/missing-file"
end
it
'rebuilds relative URL for a file in the repo with leading ./'
do
doc
=
filter
(
link
(
'./doc/api/README.md'
))
expect
(
doc
.
at_css
(
'a'
)[
'href'
])
...
...
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