Commit d8f0ada5 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'sh-fix-issue-47797' into 'master'

Fix handling of annotated tags when Gitaly is not in use

Closes gitlab-ce#47797

See merge request gitlab-org/gitlab-ee!6423
parents efd40b2d 9d8b8e64
---
title: Fix handling of annotated tags when Gitaly is not in use
merge_request:
author:
type: fixed
...@@ -142,7 +142,7 @@ module ExtractsPath ...@@ -142,7 +142,7 @@ module ExtractsPath
# When current endpoint is a Blob then `tree.blobs` will be empty, it means we need to analyze # When current endpoint is a Blob then `tree.blobs` will be empty, it means we need to analyze
# the current Blob in order to determine if it's a LFS object # the current Blob in order to determine if it's a LFS object
blob_ids = Array.wrap(@repo.blob_at(@ref, @path)&.id) if blob_ids.empty? # rubocop:disable Gitlab/ModuleWithInstanceVariables blob_ids = Array.wrap(@repo.blob_at(@commit.id, @path)&.id) if blob_ids.empty? # rubocop:disable Gitlab/ModuleWithInstanceVariables
@lfs_blob_ids = Gitlab::Git::Blob.batch_lfs_pointers(@project.repository, blob_ids).map(&:id) # rubocop:disable Gitlab/ModuleWithInstanceVariables @lfs_blob_ids = Gitlab::Git::Blob.batch_lfs_pointers(@project.repository, blob_ids).map(&:id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end end
......
...@@ -203,4 +203,30 @@ describe ExtractsPath do ...@@ -203,4 +203,30 @@ describe ExtractsPath do
expect(extract_ref_without_atom('foo.atom')).to eq(nil) expect(extract_ref_without_atom('foo.atom')).to eq(nil)
end end
end end
describe '#lfs_blob_ids' do
shared_examples '#lfs_blob_ids' do
let(:tag) { @project.repository.add_tag(@project.owner, 'my-annotated-tag', 'master', 'test tag') }
let(:ref) { tag.target }
let(:params) { { ref: ref, path: 'README.md' } }
before do
@project = create(:project, :repository)
end
it 'handles annotated tags' do
assign_ref_vars
expect(lfs_blob_ids).to eq([])
end
end
context 'when gitaly is enabled' do
it_behaves_like '#lfs_blob_ids'
end
context 'when gitaly is disabled', :skip_gitaly_mock do
it_behaves_like '#lfs_blob_ids'
end
end
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