summaryrefslogtreecommitdiff
path: root/lib/api/projects.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r--lib/api/projects.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index ce94c34bd09..75157e55730 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -493,14 +493,16 @@ module Gitlab
ref = params[:sha]
- commit = user_project.repository.commit ref
+ repo = user_project.repository
+
+ commit = repo.commit(ref)
not_found! "Commit" unless commit
- tree = Tree.new commit.tree, ref, params[:filepath]
- not_found! "File" unless tree.try(:tree)
+ blob = Gitlab::Git::Blob.new(repo, commit.id, ref, params[:filepath])
+ not_found! "File" unless blob.exists?
- content_type tree.mime_type
- present tree.data
+ content_type blob.mime_type
+ present blob.data
end
# Get a specific project's keys