Fix markdown renderer
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
f297c6b3d7
commit
31987259e4
1 changed files with 11 additions and 3 deletions
|
@ -166,14 +166,14 @@ module GitlabMarkdownHelper
|
||||||
|
|
||||||
def file_exists?(path)
|
def file_exists?(path)
|
||||||
return false if path.nil? || path.empty?
|
return false if path.nil? || path.empty?
|
||||||
return @repository.blob_at(current_ref, path).present? || @repository.tree(:head, path).entries.any?
|
return @repository.blob_at(current_sha, path).present? || @repository.tree(current_sha, 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)
|
||||||
return "tree" if @repository.tree(:head, path).entries.any?
|
return "tree" if @repository.tree(current_sha, path).entries.any?
|
||||||
return "raw" if @repository.blob_at(current_ref, path).image?
|
return "raw" if @repository.blob_at(current_sha, path).image?
|
||||||
return "blob"
|
return "blob"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -181,6 +181,14 @@ module GitlabMarkdownHelper
|
||||||
@commit.nil? ? "master" : @commit.id
|
@commit.nil? ? "master" : @commit.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_sha
|
||||||
|
if @commit
|
||||||
|
@commit.id
|
||||||
|
else
|
||||||
|
@repository.head_commit.sha
|
||||||
|
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
|
||||||
def correct_ref(ref)
|
def correct_ref(ref)
|
||||||
ref ? ref : "master"
|
ref ? ref : "master"
|
||||||
|
|
Loading…
Reference in a new issue