Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-30 16:01:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-30 16:01:17 +0300
commita114562fb6b3b350fc08225f388234a82a2700a1 (patch)
tree73331025fa884094aadef7d0d8c20c9d24d7f71a /lib/gitlab
parentfce23e13968a87a1e2de96a6e945166c372736f4 (diff)
Add latest changes from gitlab-org/security/gitlab@16-5-stable-ee
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/ci/components/instance_path.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/ci/components/instance_path.rb b/lib/gitlab/ci/components/instance_path.rb
index 551284d9099..df2b2a14fc6 100644
--- a/lib/gitlab/ci/components/instance_path.rb
+++ b/lib/gitlab/ci/components/instance_path.rb
@@ -5,6 +5,7 @@ module Gitlab
module Components
class InstancePath
include Gitlab::Utils::StrongMemoize
+ include ::Gitlab::LoopHelpers
LATEST_VERSION_KEYWORD = '~latest'
@@ -49,11 +50,18 @@ module Gitlab
# Given a path like "my-org/sub-group/the-project/path/to/component"
# find the project "my-org/sub-group/the-project" by looking at all possible paths.
def find_project_by_component_path(path)
+ return if path.start_with?('/') # exit early if path starts with `/` or it will loop forever.
+
possible_paths = [path]
+ index = nil
+
+ loop_until(limit: 20) do
+ index = path.rindex('/') # find index of last `/` in a path
+ break unless index
- while index = path.rindex('/') # find index of last `/` in a path
possible_paths << (path = path[0..index - 1])
end
+
# remove shortest path as it is group
possible_paths.pop