Commit 53bdcb53ae8891225de6c3b295a8c3f964725b81
1 parent
b75777fd
Exists in
spb-stable
and in
3 other branches
Fix relative links in markdown. Related to #6182
Showing
2 changed files
with
6 additions
and
5 deletions
Show diff stats
app/helpers/gitlab_markdown_helper.rb
... | ... | @@ -166,18 +166,18 @@ module GitlabMarkdownHelper |
166 | 166 | |
167 | 167 | def file_exists?(path) |
168 | 168 | return false if path.nil? || path.empty? |
169 | - File.exists?(path_on_fs(path)) | |
169 | + return @repository.blob_at(current_ref, path).present? || Tree.new(@repository, current_ref, path).entries.any? | |
170 | 170 | end |
171 | 171 | |
172 | 172 | # Check if the path is pointing to a directory(tree) or a file(blob) |
173 | 173 | # eg. doc/api is directory and doc/README.md is file |
174 | 174 | def local_path(path) |
175 | - File.directory?(path_on_fs(path)) ? "tree" : "blob" | |
175 | + return "tree" if Tree.new(@repository, current_ref, path).entries.any? | |
176 | + return "blob" | |
176 | 177 | end |
177 | 178 | |
178 | - # Path to the file in the satellites repository on the filesystem | |
179 | - def path_on_fs(path) | |
180 | - [@path_to_satellite, path].join("/") | |
179 | + def current_ref | |
180 | + @commit.nil? ? "master" : @commit.id | |
181 | 181 | end |
182 | 182 | |
183 | 183 | # We will assume that if no ref exists we can point to master | ... | ... |
spec/helpers/gitlab_markdown_helper_spec.rb