Skip to content
代码片段 群组 项目
提交 797c7108 编辑于 作者: Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
浏览文件

Merge branch 'ff_disable_keep_around_refs' into 'master'

No related branches found
No related tags found
无相关合并请求
---
name: disable_keep_around_refs
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124123
rollout_issue_url:
milestone: '16.1'
type: ops
group: group::gitaly
default_enabled: false
......@@ -19,6 +19,8 @@ def initialize(repository)
end
def execute(shas)
return if disabled?
shas.uniq.each do |sha|
next unless sha.present? && commit_by(oid: sha)
......@@ -32,6 +34,8 @@ def execute(shas)
end
def kept_around?(sha)
return true if disabled?
ref_exists?(keep_around_ref_name(sha))
end
......@@ -40,6 +44,11 @@ def kept_around?(sha)
private
def disabled?
Feature.enabled?(:disable_keep_around_refs, @repository, type: :ops) ||
(@repository.project && Feature.enabled?(:disable_keep_around_refs, @repository.project, type: :ops))
end
def keep_around_ref_name(sha)
"refs/#{::Repository::REF_KEEP_AROUND}/#{sha}"
end
......
......@@ -7,6 +7,7 @@
let(:repository) { create(:project, :repository).repository }
let(:service) { described_class.new(repository) }
let(:keep_around_ref_name) { "refs/#{::Repository::REF_KEEP_AROUND}/#{sample_commit.id}" }
it "does not fail if we attempt to reference bad commit" do
expect(service.kept_around?('abc1234')).to be_falsey
......@@ -16,6 +17,7 @@
service.execute([sample_commit.id])
expect(service.kept_around?(sample_commit.id)).to be_truthy
expect(repository.list_refs([keep_around_ref_name])).not_to be_empty
end
it "does not fail if writting the ref fails" do
......@@ -45,4 +47,17 @@
expect(service.kept_around?(another_sample_commit.id)).to be_truthy
end
end
context 'when disable_keep_around_refs feature flag is enabled' do
before do
stub_feature_flags(disable_keep_around_refs: true)
end
it 'does not create keep-around refs' do
service.execute([sample_commit.id])
expect(service.kept_around?(sample_commit.id)).to be_truthy
expect(repository.list_refs([keep_around_ref_name])).to be_empty
end
end
end
......@@ -312,6 +312,9 @@
# most cases. We do test the email verification flow in the appropriate specs.
stub_feature_flags(require_email_verification: false)
# Keep-around refs should only be turned off for specific projects/repositories.
stub_feature_flags(disable_keep_around_refs: false)
allow(Gitlab::GitalyClient).to receive(:can_use_disk?).and_return(enable_rugged)
else
unstub_all_feature_flags
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册