summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-04 19:14:36 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-04 19:14:36 +0200
commit31987259e4c1d878bb796d07e5594156dbcfac5c (patch)
treeb43ef4d8cca8f247ca8d63b3aa605915284e2af7 /app
parentf297c6b3d722af6fbeaa2cd5cfa30d552f6d1c41 (diff)
downloadgitlab-ce-31987259e4c1d878bb796d07e5594156dbcfac5c.tar.gz
Fix markdown renderer
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r--app/helpers/gitlab_markdown_helper.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb
index 3b9cd67636d..315f1b805b5 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/gitlab_markdown_helper.rb
@@ -166,14 +166,14 @@ module GitlabMarkdownHelper
def file_exists?(path)
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
# 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
def local_path(path)
- return "tree" if @repository.tree(:head, path).entries.any?
- return "raw" if @repository.blob_at(current_ref, path).image?
+ return "tree" if @repository.tree(current_sha, path).entries.any?
+ return "raw" if @repository.blob_at(current_sha, path).image?
return "blob"
end
@@ -181,6 +181,14 @@ module GitlabMarkdownHelper
@commit.nil? ? "master" : @commit.id
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
def correct_ref(ref)
ref ? ref : "master"