Commit 3013951c authored by Sean McGivern's avatar Sean McGivern

Merge branch 'remove-commit-tree' into 'master'

Remove the Commit#tree method

See merge request gitlab-org/gitlab-ce!16236
parents 62943cd7 ac2cb65a
...@@ -371,7 +371,7 @@ class Commit ...@@ -371,7 +371,7 @@ class Commit
# #
# Returns a symbol # Returns a symbol
def uri_type(path) def uri_type(path)
entry = @raw.tree.path(path) entry = @raw.rugged_tree_entry(path)
if entry[:type] == :blob if entry[:type] == :blob
blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]), @project) blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]), @project)
blob.image? || blob.video? ? :raw : :blob blob.image? || blob.video? ? :raw : :blob
......
...@@ -173,8 +173,8 @@ module Gitlab ...@@ -173,8 +173,8 @@ module Gitlab
end end
def find_by_rugged(repository, sha, path, limit:) def find_by_rugged(repository, sha, path, limit:)
commit = repository.lookup(sha) rugged_commit = repository.lookup(sha)
root_tree = commit.tree root_tree = rugged_commit.tree
blob_entry = find_entry_by_path(repository, root_tree.oid, path) blob_entry = find_entry_by_path(repository, root_tree.oid, path)
......
...@@ -15,8 +15,6 @@ module Gitlab ...@@ -15,8 +15,6 @@ module Gitlab
attr_accessor *SERIALIZE_KEYS # rubocop:disable Lint/AmbiguousOperator attr_accessor *SERIALIZE_KEYS # rubocop:disable Lint/AmbiguousOperator
delegate :tree, to: :rugged_commit
def ==(other) def ==(other)
return false unless other.is_a?(Gitlab::Git::Commit) return false unless other.is_a?(Gitlab::Git::Commit)
...@@ -452,6 +450,11 @@ module Gitlab ...@@ -452,6 +450,11 @@ module Gitlab
) )
end end
# Is this the same as Blob.find_entry_by_path ?
def rugged_tree_entry(path)
rugged_commit.tree.path(path)
end
private private
def init_from_hash(hash) def init_from_hash(hash)
......
...@@ -146,7 +146,7 @@ describe Gitlab::Git::Blob, seed_helper: true do ...@@ -146,7 +146,7 @@ describe Gitlab::Git::Blob, seed_helper: true do
context 'when sha references a tree' do context 'when sha references a tree' do
it 'returns nil' do it 'returns nil' do
tree = Gitlab::Git::Commit.find(repository, 'master').tree tree = repository.rugged.rev_parse('master^{tree}')
blob = Gitlab::Git::Blob.raw(repository, tree.oid) blob = Gitlab::Git::Blob.raw(repository, tree.oid)
...@@ -230,7 +230,7 @@ describe Gitlab::Git::Blob, seed_helper: true do ...@@ -230,7 +230,7 @@ describe Gitlab::Git::Blob, seed_helper: true do
end end
describe '.batch_lfs_pointers' do describe '.batch_lfs_pointers' do
let(:tree_object) { Gitlab::Git::Commit.find(repository, 'master').tree } let(:tree_object) { repository.rugged.rev_parse('master^{tree}') }
let(:non_lfs_blob) do let(:non_lfs_blob) do
Gitlab::Git::Blob.find( Gitlab::Git::Blob.find(
......
...@@ -55,7 +55,6 @@ describe Gitlab::Git::Commit, seed_helper: true do ...@@ -55,7 +55,6 @@ describe Gitlab::Git::Commit, seed_helper: true do
it { expect(@commit.parents).to eq(@gitlab_parents) } it { expect(@commit.parents).to eq(@gitlab_parents) }
it { expect(@commit.parent_id).to eq(@parents.first.oid) } it { expect(@commit.parent_id).to eq(@parents.first.oid) }
it { expect(@commit.no_commit_message).to eq("--no commit message") } it { expect(@commit.no_commit_message).to eq("--no commit message") }
it { expect(@commit.tree).to eq(@tree) }
after do after do
# Erase the new commit so other tests get the original repo # Erase the new commit so other tests get the original repo
......
...@@ -181,7 +181,6 @@ eos ...@@ -181,7 +181,6 @@ eos
it { is_expected.to respond_to(:parents) } it { is_expected.to respond_to(:parents) }
it { is_expected.to respond_to(:date) } it { is_expected.to respond_to(:date) }
it { is_expected.to respond_to(:diffs) } it { is_expected.to respond_to(:diffs) }
it { is_expected.to respond_to(:tree) }
it { is_expected.to respond_to(:id) } it { is_expected.to respond_to(:id) }
it { is_expected.to respond_to(:to_patch) } it { is_expected.to respond_to(:to_patch) }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment