diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index d5c35ccca867eed3127a1c1bc9436bcb39f8bdbb..2e13708467db68f60d21d430966a5ea476b7d29a 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -97,14 +97,10 @@ def check_issues_available! def set_is_ambiguous_ref return @is_ambiguous_ref if defined? @is_ambiguous_ref - @is_ambiguous_ref = if Feature.enabled?(:ambiguous_ref_modal, @project) - ExtractsRef::RequestedRef + @is_ambiguous_ref = ExtractsRef::RequestedRef .new(@project.repository, ref_type: ref_type, ref: @ref) .find .fetch(:ambiguous, false) - else - false - end end def handle_update_result(result) diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index f0fcb7cf347425edcde27e4658a5ac7ad2dda871..2709aeb99c7c7a26185441c63472186035612700 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -156,12 +156,6 @@ def blob def check_for_ambiguous_ref @ref_type = ref_type - return if Feature.enabled?(:ambiguous_ref_modal, @project) - - if @ref_type == ExtractsRef::RefExtractor::BRANCH_REF_TYPE && ambiguous_ref?(@project, @ref) - branch = @project.repository.find_branch(@ref) - redirect_to project_blob_path(@project, File.join(branch.target, @path)) - end end def commit diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index c49f33d760a0c798badb2e2d39823bdc73cc3b9b..6ff588a9be562f25ca4e00ce5314a2436425c0e2 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -29,14 +29,6 @@ def show return render_404 unless @commit @ref_type = ref_type - if !Feature.enabled?(:ambiguous_ref_modal, - @project) && (@ref_type == BRANCH_REF_TYPE && ambiguous_ref?(@project, @ref)) - branch = @project.repository.find_branch(@ref) - if branch - redirect_to project_tree_path(@project, branch.target) - return - end - end if tree.entries.empty? if @repository.blob_at(@commit.id, @path) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 4ee996d14a1f11c553bff7bd166510fcc9466662..ef5c491da4575af2a596f9f6dfede1203041daa8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -177,15 +177,6 @@ def show @ref_type = 'heads' - if !Feature.enabled?(:ambiguous_ref_modal, @project) && ambiguous_ref?(@project, @ref) - branch = @project.repository.find_branch(@ref) - - # The files view would render a ref other than the default branch - # This redirect can be removed once the view is fixed - redirect_to(project_tree_path(@project, branch.target), alert: _("The default branch of this project clashes with another ref")) - return - end - respond_to do |format| format.html do @project = @project.present(current_user: current_user) diff --git a/config/feature_flags/development/ambiguous_ref_modal.yml b/config/feature_flags/development/ambiguous_ref_modal.yml deleted file mode 100644 index c1cc52682e2998baabedaa123b39218a01ceca4a..0000000000000000000000000000000000000000 --- a/config/feature_flags/development/ambiguous_ref_modal.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: ambiguous_ref_modal -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/133093 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/429523 -milestone: '16.6' -type: development -group: group::source code -default_enabled: false diff --git a/locale/gitlab.pot b/locale/gitlab.pot index b8fe0478d2f3aa73a5de35cea6c5d8b58bc6701b..5685389087fd42a7fcdae1af3c979e52b5e71bf9 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -51600,9 +51600,6 @@ msgstr "" msgid "The default branch for this project has been changed. Please update your bookmarks." msgstr "" -msgid "The default branch of this project clashes with another ref" -msgstr "" - msgid "The dependency list details information about the components used within your project." msgstr "" diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index 0c431d217b9e8a48519bff30e29a2857f48e6554..3ab96a1a2b98a89c79046fd163ad995a98659ec6 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -29,27 +29,10 @@ let(:id) { "#{ref}/#{path}" } it_behaves_like '#set_is_ambiguous_ref when ref is ambiguous' - - context 'and explicitly requesting a branch' do - let(:ref_type) { 'heads' } - - it 'redirects to blob#show with sha for the branch' do - expect(response).to redirect_to(project_blob_path(project, "#{RepoHelpers.another_sample_commit.id}/#{path}")) - end - end - - context 'and explicitly requesting a tag' do - let(:ref_type) { 'tags' } - - it 'responds with success' do - expect(response).to be_ok - end - end end describe '#set_is_ambiguous_ref with no ambiguous ref' do let(:id) { 'master/invalid-path.rb' } - let(:ambiguous_ref_modal) { true } it_behaves_like '#set_is_ambiguous_ref when ref is not ambiguous' end diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb index 86ef379bacf8b9283512ff44f5b5cb4738fdd125..1c30d8bdc3cc1e4ba7179a90d988a05fa066b430 100644 --- a/spec/controllers/projects/tree_controller_spec.rb +++ b/spec/controllers/projects/tree_controller_spec.rb @@ -47,29 +47,6 @@ end end - context 'when there is a ref and tag with the same name' do - let(:id) { 'ambiguous_ref' } - let(:params) { { namespace_id: project.namespace, project_id: project, id: id, ref_type: ref_type } } - - context 'and explicitly requesting a branch' do - let(:ref_type) { 'heads' } - - it 'redirects to blob#show with sha for the branch' do - request - expect(response).to redirect_to(project_tree_path(project, RepoHelpers.another_sample_commit.id)) - end - end - - context 'and explicitly requesting a tag' do - let(:ref_type) { 'tags' } - - it 'responds with success' do - request - expect(response).to be_ok - end - end - end - context "valid branch, no path" do let(:id) { 'flatten-dir' } diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index e4810fffc4ec919b2d4ca21a0993b18141a3a75c..3d7686c9c75ad6be0ea9580ee226f9cf2ae5884d 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -173,122 +173,6 @@ def get_activity(project) sign_in(user) end - context "user has access to project" do - before do - expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original - end - - context 'when ambiguous_ref_modal is disabled' do - before do - stub_feature_flags(ambiguous_ref_modal: false) - end - - context 'when there is a tag with the same name as the default branch' do - let_it_be(:tagged_project) { create(:project, :public, :custom_repo, files: ['somefile']) } - let(:tree_with_default_branch) do - branch = tagged_project.repository.find_branch(tagged_project.default_branch) - project_tree_path(tagged_project, branch.target) - end - - before do - tagged_project.repository.create_file( - tagged_project.creator, - 'file_for_tag', - 'content for file', - message: "Automatically created file", - branch_name: 'branch-to-tag' - ) - - tagged_project.repository.add_tag( - tagged_project.creator, - tagged_project.default_branch, # tag name - 'branch-to-tag' # target - ) - end - - it 'redirects to tree view for the default branch' do - get :show, params: { namespace_id: tagged_project.namespace, id: tagged_project } - expect(response).to redirect_to(tree_with_default_branch) - end - end - - context 'when the default branch name is ambiguous' do - let_it_be(:project_with_default_branch) do - create(:project, :public, :custom_repo, files: ['somefile']) - end - - shared_examples 'ambiguous ref redirects' do - let(:project) { project_with_default_branch } - let(:branch_ref) { "refs/heads/#{ref}" } - let(:repo) { project.repository } - - before do - repo.create_branch(branch_ref, 'master') - repo.change_head(ref) - end - - after do - repo.change_head('master') - repo.delete_branch(branch_ref) - end - - subject do - get( - :show, - params: { - namespace_id: project.namespace, - id: project - } - ) - end - - context 'when there is no conflicting ref' do - let(:other_ref) { 'non-existent-ref' } - - it { is_expected.to have_gitlab_http_status(:ok) } - end - - context 'and that other ref exists' do - let(:other_ref) { 'master' } - - let(:project_default_root_tree_path) do - sha = repo.find_branch(project.default_branch).target - project_tree_path(project, sha) - end - - it 'redirects to tree view for the default branch' do - is_expected.to redirect_to(project_default_root_tree_path) - end - end - end - - context 'when ref starts with ref/heads/' do - let(:ref) { "refs/heads/#{other_ref}" } - - include_examples 'ambiguous ref redirects' - end - - context 'when ref starts with ref/tags/' do - let(:ref) { "refs/tags/#{other_ref}" } - - include_examples 'ambiguous ref redirects' - end - - context 'when ref starts with heads/' do - let(:ref) { "heads/#{other_ref}" } - - include_examples 'ambiguous ref redirects' - end - - context 'when ref starts with tags/' do - let(:ref) { "tags/#{other_ref}" } - - include_examples 'ambiguous ref redirects' - end - end - end - end - describe "when project repository is disabled" do render_views diff --git a/spec/support/shared_contexts/controllers/ambiguous_ref_controller_shared_context.rb b/spec/support/shared_contexts/controllers/ambiguous_ref_controller_shared_context.rb index 28598a387bd1c961ddfcb4a81bdf7901a565fd15..0d67a986da88d859fca091ba0982b966ffa6434a 100644 --- a/spec/support/shared_contexts/controllers/ambiguous_ref_controller_shared_context.rb +++ b/spec/support/shared_contexts/controllers/ambiguous_ref_controller_shared_context.rb @@ -1,14 +1,10 @@ # frozen_string_literal: true RSpec.shared_context 'with ambiguous refs for controllers' do - let(:ambiguous_ref_modal) { false } - before do expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original # rubocop:disable RSpec/ExpectInHook project.repository.add_tag(project.creator, 'ambiguous_ref', RepoHelpers.sample_commit.id) project.repository.add_branch(project.creator, 'ambiguous_ref', RepoHelpers.another_sample_commit.id) - - stub_feature_flags(ambiguous_ref_modal: ambiguous_ref_modal) end after do diff --git a/spec/support/shared_examples/controllers/is_ambiguous_ref_examples.rb b/spec/support/shared_examples/controllers/is_ambiguous_ref_examples.rb index 24a656514c49b9654e7d8e144a640d90cb4342c1..e420b1af62af016e66add4dc90b6556f32ae8129 100644 --- a/spec/support/shared_examples/controllers/is_ambiguous_ref_examples.rb +++ b/spec/support/shared_examples/controllers/is_ambiguous_ref_examples.rb @@ -4,38 +4,21 @@ context 'when the ref_type is nil' do let(:ref_type) { nil } - it '@ambiguous_ref return false when ff is disabled' do - expect(controller.instance_variable_get(:@is_ambiguous_ref)).to eq(false) - end - - context 'when the ambiguous_ref_modal ff is enabled' do - let(:ambiguous_ref_modal) { true } - - it '@ambiguous_ref return true' do - expect(controller.instance_variable_get(:@is_ambiguous_ref)).to eq(true) - end + it '@ambiguous_ref return true' do + expect(controller.instance_variable_get(:@is_ambiguous_ref)).to eq(true) end end context 'when the ref_type is empty' do let(:ref_type) { '' } - it '@ambiguous_ref return false when ff is disabled' do - expect(controller.instance_variable_get(:@is_ambiguous_ref)).to eq(false) - end - - context 'when the ambiguous_ref_modal ff is enabled' do - let(:ambiguous_ref_modal) { true } - - it '@ambiguous_ref return true' do - expect(controller.instance_variable_get(:@is_ambiguous_ref)).to eq(true) - end + it '@ambiguous_ref return true' do + expect(controller.instance_variable_get(:@is_ambiguous_ref)).to eq(true) end end context 'when the ref_type is present' do let(:ref_type) { 'heads' } - let(:ambiguous_ref_modal) { true } it '@ambiguous_ref return false' do expect(controller.instance_variable_get(:@is_ambiguous_ref)).to eq(false) @@ -46,7 +29,6 @@ RSpec.shared_examples '#set_is_ambiguous_ref when ref is not ambiguous' do context 'when the ref_type is nil' do let(:ref_type) { nil } - let(:ambiguous_ref_modal) { true } it '@ambiguous_ref return false' do expect(controller.instance_variable_get(:@is_ambiguous_ref)).to eq(false)