summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-01 16:12:56 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-01 16:12:56 +0000
commit68d89548cd7d796c78e7b9d3f7b64702d39d0f5c (patch)
tree57e16cc0e7dc0f05cbee202ca0d6fd8a7b82b591 /lib
parente219cf7246c6a0495e4507deaffeba11e79f13b8 (diff)
parent1d3f03fb69111e25a33ccb7f66582904ad0371f8 (diff)
downloadgitlab-ce-68d89548cd7d796c78e7b9d3f7b64702d39d0f5c.tar.gz
Merge branch 'improve/gitlab_git_3' of /home/git/repositories/gitlab/gitlabhq
Diffstat (limited to 'lib')
-rw-r--r--lib/api/repositories.rb6
-rw-r--r--lib/extracts_path.rb10
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb
index c2b229b0172..1a911eae2bb 100644
--- a/lib/api/repositories.rb
+++ b/lib/api/repositories.rb
@@ -139,7 +139,7 @@ module API
path = params[:path] || nil
commit = user_project.repository.commit(ref)
- tree = Tree.new(user_project.repository, commit.id, ref, path)
+ tree = Tree.new(user_project.repository, commit.id, path)
trees = []
@@ -168,8 +168,8 @@ module API
commit = repo.commit(ref)
not_found! "Commit" unless commit
- blob = Gitlab::Git::Blob.new(repo, commit.id, ref, params[:filepath])
- not_found! "File" unless blob.exists?
+ blob = Gitlab::Git::Blob.find(repo, commit.id, params[:filepath])
+ not_found! "File" unless blob
env['api.format'] = :txt
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index 53bc079296a..6e7872dcd03 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -86,7 +86,6 @@ module ExtractsPath
# - @ref - A string representing the ref (e.g., the branch, tag, or commit SHA)
# - @path - A string representing the filesystem path
# - @commit - A Commit representing the commit from the given ref
- # - @tree - A Tree representing the tree at the given ref/path
#
# If the :id parameter appears to be requesting a specific response format,
# that will be handled as well.
@@ -107,15 +106,20 @@ module ExtractsPath
else
@commit = @repo.commit(@options[:extended_sha1])
end
- @tree = Tree.new(@repo, @commit.id, @ref, @path)
+
+ raise InvalidPathError unless @commit
+
@hex_path = Digest::SHA1.hexdigest(@path)
@logs_path = logs_file_project_ref_path(@project, @ref, @path)
- raise InvalidPathError unless @tree.exists?
rescue RuntimeError, NoMethodError, InvalidPathError
not_found!
end
+ def tree
+ @tree ||= Tree.new(@repo, @commit.id, @path)
+ end
+
private
def get_id