From ae9dd6276267e0df2d9c2da3b89393e4ee212175 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 1 Oct 2013 17:00:28 +0300 Subject: Update code to work with gitlab_git 3 --- lib/extracts_path.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index 53bc079296a..5f28d624402 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,18 @@ module ExtractsPath else @commit = @repo.commit(@options[:extended_sha1]) end - @tree = Tree.new(@repo, @commit.id, @ref, @path) + @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 -- cgit v1.2.1 From 1d3f03fb69111e25a33ccb7f66582904ad0371f8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 1 Oct 2013 18:26:55 +0300 Subject: Fix blob and repo stuff after gitlab_git v3 --- lib/api/repositories.rb | 6 +++--- lib/extracts_path.rb | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') 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 5f28d624402..6e7872dcd03 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -107,6 +107,8 @@ module ExtractsPath @commit = @repo.commit(@options[:extended_sha1]) end + raise InvalidPathError unless @commit + @hex_path = Digest::SHA1.hexdigest(@path) @logs_path = logs_file_project_ref_path(@project, @ref, @path) -- cgit v1.2.1