Commit 31987259e4c1d878bb796d07e5594156dbcfac5c
1 parent
f297c6b3
Exists in
spb-stable
and in
3 other branches
Fix markdown renderer
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
1 changed file
with
11 additions
and
3 deletions
Show diff stats
app/helpers/gitlab_markdown_helper.rb
@@ -166,14 +166,14 @@ module GitlabMarkdownHelper | @@ -166,14 +166,14 @@ module GitlabMarkdownHelper | ||
166 | 166 | ||
167 | def file_exists?(path) | 167 | def file_exists?(path) |
168 | return false if path.nil? || path.empty? | 168 | return false if path.nil? || path.empty? |
169 | - return @repository.blob_at(current_ref, path).present? || @repository.tree(:head, path).entries.any? | 169 | + return @repository.blob_at(current_sha, path).present? || @repository.tree(current_sha, path).entries.any? |
170 | end | 170 | end |
171 | 171 | ||
172 | # Check if the path is pointing to a directory(tree) or a file(blob) | 172 | # Check if the path is pointing to a directory(tree) or a file(blob) |
173 | # eg. doc/api is directory and doc/README.md is file | 173 | # eg. doc/api is directory and doc/README.md is file |
174 | def local_path(path) | 174 | def local_path(path) |
175 | - return "tree" if @repository.tree(:head, path).entries.any? | ||
176 | - return "raw" if @repository.blob_at(current_ref, path).image? | 175 | + return "tree" if @repository.tree(current_sha, path).entries.any? |
176 | + return "raw" if @repository.blob_at(current_sha, path).image? | ||
177 | return "blob" | 177 | return "blob" |
178 | end | 178 | end |
179 | 179 | ||
@@ -181,6 +181,14 @@ module GitlabMarkdownHelper | @@ -181,6 +181,14 @@ module GitlabMarkdownHelper | ||
181 | @commit.nil? ? "master" : @commit.id | 181 | @commit.nil? ? "master" : @commit.id |
182 | end | 182 | end |
183 | 183 | ||
184 | + def current_sha | ||
185 | + if @commit | ||
186 | + @commit.id | ||
187 | + else | ||
188 | + @repository.head_commit.sha | ||
189 | + end | ||
190 | + end | ||
191 | + | ||
184 | # We will assume that if no ref exists we can point to master | 192 | # We will assume that if no ref exists we can point to master |
185 | def correct_ref(ref) | 193 | def correct_ref(ref) |
186 | ref ? ref : "master" | 194 | ref ? ref : "master" |