diff --git a/app/models/repository.rb b/app/models/repository.rb index 6045b899743b5d9e68c3b7ba668c112ba4008932..ae39056b774da4abe399f243869ed2ca3017ad6e 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -153,7 +153,7 @@ def commits(ref = nil, opts = {}) ref: ref, path: opts[:path], author: opts[:author], - follow: Array(opts[:path]).length == 1, + follow: Array(opts[:path]).length == 1 && Feature.disabled?(:remove_file_commit_history_following, type: :ops), limit: opts[:limit], offset: opts[:offset], skip_merges: !!opts[:skip_merges], diff --git a/config/feature_flags/ops/remove_file_commit_history_following.yml b/config/feature_flags/ops/remove_file_commit_history_following.yml new file mode 100644 index 0000000000000000000000000000000000000000..872bcf1ab645ee22880be2549e60a79550dfdd5f --- /dev/null +++ b/config/feature_flags/ops/remove_file_commit_history_following.yml @@ -0,0 +1,9 @@ +--- +name: remove_file_commit_history_following +feature_issue_url: https://gitlab.com/gitlab-org/gitaly/-/issues/5821 +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144263 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/441312 +milestone: '16.10' +group: group::gitaly +type: ops +default_enabled: false diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index b6cb2464605d8c6a09c017febef94659b3549a9a..25afbd625b306b9fcbced50a4b59164b70e4b246 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -398,8 +398,21 @@ def expect_to_raise_storage_error end context 'with path' do - it 'sets follow when it is a single path' do - expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: true)).and_call_original.twice + context 'when remove_file_commit_history_following feature flag is disabled' do + before do + stub_feature_flags(remove_file_commit_history_following: false) + end + + it 'sets follow when it is a single path' do + expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: true)).and_call_original.twice + + repository.commits('master', limit: 1, path: 'README.md') + repository.commits('master', limit: 1, path: ['README.md']) + end + end + + it 'does not set follow when it is a single path' do + expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: false)).and_call_original.twice repository.commits('master', limit: 1, path: 'README.md') repository.commits('master', limit: 1, path: ['README.md'])