diff options
author | Rémy Coutable <remy@rymai.me> | 2018-07-11 09:25:54 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-07-11 09:25:54 +0000 |
commit | d2ea56a87026de92f31bbcfb360748fcf766b835 (patch) | |
tree | 93313adae99ae6d59599863b53e1ebe79fa92cf2 | |
parent | eae40e700bd7291300558900a79bff7574c12cca (diff) | |
parent | e4047ad6f9ae0f4ff2ba3d19fedb8902213b9edb (diff) | |
download | gitlab-ce-d2ea56a87026de92f31bbcfb360748fcf766b835.tar.gz |
Merge branch '46519-remove-ce-prefix-suffix-in-check-ce' into 'master'bjk/health_help
Resolve "ee_compat_check should remove `ce-` prefix or `-ce` suffix as ee-specific check"
Closes #46519
See merge request gitlab-org/gitlab-ce!20532
-rw-r--r-- | lib/gitlab/ee_compat_check.rb | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/gitlab/ee_compat_check.rb b/lib/gitlab/ee_compat_check.rb index 8c72d00c1f3..ee604e66154 100644 --- a/lib/gitlab/ee_compat_check.rb +++ b/lib/gitlab/ee_compat_check.rb @@ -138,15 +138,23 @@ module Gitlab def ee_branch_presence_check! ee_remotes.keys.each do |remote| - [ce_branch, ee_branch_prefix, ee_branch_suffix].each do |branch| - _, status = step("Fetching #{remote}/#{branch}", %W[git fetch #{remote} #{branch}]) + output, _ = step( + "Searching #{remote}", + %W[git ls-remote #{remote} *#{minimal_ee_branch_name}*]) - if status.zero? - @ee_remote_with_branch = remote - @ee_branch_found = branch - return true - end - end + branches = + output.scan(%r{(?<=refs/heads/|refs/tags/).+}).sort_by(&:size) + + next if branches.empty? + + branch = branches.first + + step("Fetching #{remote}/#{branch}", %W[git fetch #{remote} #{branch}]) + + @ee_remote_with_branch = remote + @ee_branch_found = branch + + return true end puts @@ -271,6 +279,10 @@ module Gitlab @ee_patch_full_path ||= patches_dir.join(ee_patch_name) end + def minimal_ee_branch_name + @minimal_ee_branch_name ||= ce_branch.sub(/(\Ace\-|\-ce\z)/, '') + end + def patch_name_from_branch(branch_name) branch_name.parameterize << '.patch' end |