From 7e5ae6d6dac929cc94e4bb9df65c0285fe72456d Mon Sep 17 00:00:00 2001
From: Vasilii Iakliushin <viakliushin@gitlab.com>
Date: Fri, 1 Mar 2024 16:48:04 +0100
Subject: [PATCH] Remove "ref_extract_sha256" feature flag

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/442021

* Extend regex to support SHA256 commits.

Changelog: changed
---
 .../gitlab_com_derisk/ref_extract_sha256.yml  |  9 -------
 lib/extracts_ref.rb                           |  9 +------
 .../path_extraction_shared_examples.rb        | 24 -------------------
 3 files changed, 1 insertion(+), 41 deletions(-)
 delete mode 100644 config/feature_flags/gitlab_com_derisk/ref_extract_sha256.yml

diff --git a/config/feature_flags/gitlab_com_derisk/ref_extract_sha256.yml b/config/feature_flags/gitlab_com_derisk/ref_extract_sha256.yml
deleted file mode 100644
index 84370a6c36c51..0000000000000
--- a/config/feature_flags/gitlab_com_derisk/ref_extract_sha256.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-name: ref_extract_sha256
-feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/419905
-introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144853
-rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/442021
-milestone: '16.10'
-group: group::source code
-type: gitlab_com_derisk
-default_enabled: false
diff --git a/lib/extracts_ref.rb b/lib/extracts_ref.rb
index 90414d3f98b46..59557a8eb3768 100644
--- a/lib/extracts_ref.rb
+++ b/lib/extracts_ref.rb
@@ -109,15 +109,8 @@ def ref_type
   def extract_raw_ref(id)
     return ['', ''] unless repository_container
 
-    sha_regex =
-      if Feature.enabled?(:ref_extract_sha256, Feature.current_request)
-        /^(\h{40}\h{24}?)(.*)/
-      else
-        /^(\h{40})(.+)/
-      end
-
     # If the ref appears to be a SHA, we're done, just split the string
-    return $~.captures if id =~ sha_regex
+    return $~.captures if id =~ /^(\h{40}\h{24}?)(.*)/
 
     # No slash means we must have a ref and no path
     return [id, ''] unless id.include?('/')
diff --git a/spec/support/shared_examples/path_extraction_shared_examples.rb b/spec/support/shared_examples/path_extraction_shared_examples.rb
index 6bc6a84e8b4c1..8f2aa829f18ff 100644
--- a/spec/support/shared_examples/path_extraction_shared_examples.rb
+++ b/spec/support/shared_examples/path_extraction_shared_examples.rb
@@ -91,18 +91,6 @@
         )
       end
 
-      context 'when feature flag "ref_extract_sha256" is disabled' do
-        before do
-          stub_feature_flags(ref_extract_sha256: false)
-        end
-
-        it 'cannot extract a valid commit SHA256 ref' do
-          expect(extract_ref('34627760127d5ff2a644771225af09bbd79f28a54a0a4c03c1881bf2c26dc13c')).to eq(
-            %w[34627760127d5ff2a644771225af09bbd79f28a5 4a0a4c03c1881bf2c26dc13c]
-          )
-        end
-      end
-
       it 'falls back to a primitive split for an invalid ref' do
         expect(extract_ref('stable')).to eq(['stable', ''])
       end
@@ -142,18 +130,6 @@
         )
       end
 
-      context 'when feature flag "ref_extract_sha256" is disabled' do
-        before do
-          stub_feature_flags(ref_extract_sha256: false)
-        end
-
-        it 'cannot extract a valid commit SHA256 ref' do
-          expect(extract_ref('34627760127d5ff2a644771225af09bbd79f28a54a0a4c03c1881bf2c26dc13c/CHANGELOG')).to eq(
-            ['34627760127d5ff2a644771225af09bbd79f28a5', '4a0a4c03c1881bf2c26dc13c/CHANGELOG']
-          )
-        end
-      end
-
       it 'falls back to a primitive split for an invalid ref' do
         expect(extract_ref('stable/CHANGELOG')).to eq(%w[stable CHANGELOG])
       end
-- 
GitLab