mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-07-25 16:03:48 +00:00
20 lines
577 B
Ruby
20 lines
577 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module Utils
|
|
module Job
|
|
class << self
|
|
def group_name(job_name)
|
|
# [\b\s:] -> whitespace or column
|
|
# (\[.*\])|(\d+[\s:\/\\]+\d+) -> variables/matrix or parallel-jobs numbers
|
|
# {1,3} -> number of times that matches the variables/matrix or parallel-jobs numbers
|
|
# we limit this to 3 because of possible abuse
|
|
regex = %r{([\b\s:]+((\[.*\])|(\d+[\s:\/\\]+\d+))){1,3}\s*\z}
|
|
|
|
job_name.to_s.sub(regex, '').strip
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|