summaryrefslogtreecommitdiff
path: root/lib/gitlab/task_helpers.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/task_helpers.rb')
-rw-r--r--lib/gitlab/task_helpers.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/gitlab/task_helpers.rb b/lib/gitlab/task_helpers.rb
index 8532845f3cb..ac02ec635e4 100644
--- a/lib/gitlab/task_helpers.rb
+++ b/lib/gitlab/task_helpers.rb
@@ -158,15 +158,17 @@ module Gitlab
end
def checkout_or_clone_version(version:, repo:, target_dir:)
- version =
- if version.starts_with?("=")
- version.sub(/\A=/, '') # tag or branch
- else
- "v#{version}" # tag
- end
-
clone_repo(repo, target_dir) unless Dir.exist?(target_dir)
- checkout_version(version, target_dir)
+ checkout_version(get_version(version), target_dir)
+ end
+
+ # this function implements the same logic we have in omnibus for dealing with components version
+ def get_version(component_version)
+ # If not a valid version string following SemVer it is probably a branch name or a SHA
+ # commit of one of our own component so it doesn't need `v` prepended
+ return component_version unless /^\d+\.\d+\.\d+(-rc\d+)?$/.match?(component_version)
+
+ "v#{component_version}"
end
def clone_repo(repo, target_dir)