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
Jérome Perrin
gitlab-ce
Commits
580db8de
Commit
580db8de
authored
Jan 29, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6183 from Undev/fix_links_in_markdown
Fix relative links in markdown. Related to #6182
parents
b75777fd
53bdcb53
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
app/helpers/gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+5
-5
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+1
-0
No files found.
app/helpers/gitlab_markdown_helper.rb
View file @
580db8de
...
@@ -166,18 +166,18 @@ module GitlabMarkdownHelper
...
@@ -166,18 +166,18 @@ module GitlabMarkdownHelper
def
file_exists?
(
path
)
def
file_exists?
(
path
)
return
false
if
path
.
nil?
||
path
.
empty?
return
false
if
path
.
nil?
||
path
.
empty?
File
.
exists?
(
path_on_fs
(
path
))
return
@repository
.
blob_at
(
current_ref
,
path
).
present?
||
Tree
.
new
(
@repository
,
current_ref
,
path
).
entries
.
any?
end
end
# Check if the path is pointing to a directory(tree) or a file(blob)
# Check if the path is pointing to a directory(tree) or a file(blob)
# eg. doc/api is directory and doc/README.md is file
# eg. doc/api is directory and doc/README.md is file
def
local_path
(
path
)
def
local_path
(
path
)
File
.
directory?
(
path_on_fs
(
path
))
?
"tree"
:
"blob"
return
"tree"
if
Tree
.
new
(
@repository
,
current_ref
,
path
).
entries
.
any?
return
"blob"
end
end
# Path to the file in the satellites repository on the filesystem
def
current_ref
def
path_on_fs
(
path
)
@commit
.
nil?
?
"master"
:
@commit
.
id
[
@path_to_satellite
,
path
].
join
(
"/"
)
end
end
# We will assume that if no ref exists we can point to master
# We will assume that if no ref exists we can point to master
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
580db8de
...
@@ -16,6 +16,7 @@ describe GitlabMarkdownHelper do
...
@@ -16,6 +16,7 @@ describe GitlabMarkdownHelper do
before
do
before
do
# Helper expects a @project instance variable
# Helper expects a @project instance variable
@project
=
project
@project
=
project
@repository
=
project
.
repository
end
end
describe
"#gfm"
do
describe
"#gfm"
do
...
...
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