2018-10-22 03:00:50 -04:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-10-24 15:19:46 -04:00
|
|
|
|
# rubocop: disable Rails/Output
|
2016-10-17 12:52:14 -04:00
|
|
|
|
module Gitlab
|
|
|
|
|
# Checks if a set of migrations requires downtime or not.
|
|
|
|
|
class EeCompatCheck
|
2018-03-05 11:24:26 -05:00
|
|
|
|
CANONICAL_CE_PROJECT_URL = 'https://gitlab.com/gitlab-org/gitlab-ce'.freeze
|
|
|
|
|
CANONICAL_EE_REPO_URL = 'https://gitlab.com/gitlab-org/gitlab-ee.git'.freeze
|
2016-10-28 12:13:59 -04:00
|
|
|
|
CHECK_DIR = Rails.root.join('ee_compat_check')
|
2019-08-02 02:24:07 -04:00
|
|
|
|
IGNORED_FILES_REGEX = /VERSION|CHANGELOG\.md|doc\/.+/i.freeze
|
2017-03-23 14:15:56 -04:00
|
|
|
|
PLEASE_READ_THIS_BANNER = %Q{
|
|
|
|
|
============================================================
|
|
|
|
|
===================== PLEASE READ THIS =====================
|
|
|
|
|
============================================================
|
|
|
|
|
}.freeze
|
2018-03-05 11:24:26 -05:00
|
|
|
|
STAY_STRONG_LINK_TO_DOCS = %Q{
|
|
|
|
|
Stay 💪! For more information, see
|
|
|
|
|
https://docs.gitlab.com/ce/development/automatic_ce_ee_merge.html
|
|
|
|
|
}.freeze
|
2017-03-23 14:15:56 -04:00
|
|
|
|
THANKS_FOR_READING_BANNER = %Q{
|
|
|
|
|
============================================================
|
|
|
|
|
==================== THANKS FOR READING ====================
|
|
|
|
|
============================================================\n
|
|
|
|
|
}.freeze
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
attr_reader :ee_repo_dir, :patches_dir
|
|
|
|
|
attr_reader :ce_project_url, :ee_repo_url
|
|
|
|
|
attr_reader :ce_branch, :ee_remote_with_branch, :ee_branch_found
|
2017-10-31 09:24:45 -04:00
|
|
|
|
attr_reader :job_id, :failed_files
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
def initialize(branch:, ce_project_url: CANONICAL_CE_PROJECT_URL, job_id: nil)
|
2017-02-23 04:09:55 -05:00
|
|
|
|
@ee_repo_dir = CHECK_DIR.join('ee-repo')
|
2016-10-28 12:13:59 -04:00
|
|
|
|
@patches_dir = CHECK_DIR.join('patches')
|
2016-10-17 12:52:14 -04:00
|
|
|
|
@ce_branch = branch
|
2017-10-31 09:24:45 -04:00
|
|
|
|
@ce_project_url = ce_project_url
|
2018-03-05 11:24:26 -05:00
|
|
|
|
@ee_repo_url = ce_public_repo_url.sub('gitlab-ce', 'gitlab-ee')
|
2017-10-31 09:24:45 -04:00
|
|
|
|
@job_id = job_id
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def check
|
2016-10-28 12:13:59 -04:00
|
|
|
|
ensure_patches_dir
|
2018-03-05 11:24:26 -05:00
|
|
|
|
# We're generating the patch against the canonical-ce remote since forks'
|
|
|
|
|
# master branch are not necessarily up-to-date.
|
|
|
|
|
add_remote('canonical-ce', "#{CANONICAL_CE_PROJECT_URL}.git")
|
|
|
|
|
generate_patch(branch: ce_branch, patch_path: ce_patch_full_path, branch_remote: 'origin', master_remote: 'canonical-ce')
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
ensure_ee_repo
|
|
|
|
|
Dir.chdir(ee_repo_dir) do
|
|
|
|
|
step("In the #{ee_repo_dir} directory")
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
ee_remotes.each do |key, url|
|
|
|
|
|
add_remote(key, url)
|
|
|
|
|
end
|
|
|
|
|
fetch(branch: 'master', depth: 20, remote: 'canonical-ee')
|
2017-11-20 11:16:45 -05:00
|
|
|
|
|
2016-10-17 12:52:14 -04:00
|
|
|
|
status = catch(:halt_check) do
|
|
|
|
|
ce_branch_compat_check!
|
2017-02-23 04:09:55 -05:00
|
|
|
|
delete_ee_branches_locally!
|
2016-10-17 12:52:14 -04:00
|
|
|
|
ee_branch_presence_check!
|
2017-11-20 11:16:45 -05:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
step("Checking out #{ee_remote_with_branch}/#{ee_branch_found}", %W[git checkout -b #{ee_branch_found} #{ee_remote_with_branch}/#{ee_branch_found}])
|
|
|
|
|
generate_patch(branch: ee_branch_found, patch_path: ee_patch_full_path, branch_remote: ee_remote_with_branch, master_remote: 'canonical-ee')
|
2016-10-17 12:52:14 -04:00
|
|
|
|
ee_branch_compat_check!
|
|
|
|
|
end
|
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
delete_ee_branches_locally!
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
status.nil?
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
def fork?
|
|
|
|
|
ce_project_url != CANONICAL_CE_PROJECT_URL
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ee_remotes
|
|
|
|
|
return @ee_remotes if defined?(@ee_remotes)
|
|
|
|
|
|
|
|
|
|
remotes =
|
|
|
|
|
{
|
|
|
|
|
'ee' => ee_repo_url,
|
|
|
|
|
'canonical-ee' => CANONICAL_EE_REPO_URL
|
|
|
|
|
}
|
|
|
|
|
remotes.delete('ee') unless fork?
|
|
|
|
|
|
|
|
|
|
@ee_remotes = remotes
|
|
|
|
|
end
|
|
|
|
|
|
2017-11-20 11:16:45 -05:00
|
|
|
|
def add_remote(name, url)
|
|
|
|
|
step(
|
|
|
|
|
"Adding the #{name} remote (#{url})",
|
|
|
|
|
%W[git remote add #{name} #{url}]
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
2016-10-17 12:52:14 -04:00
|
|
|
|
def ensure_ee_repo
|
2018-03-05 11:24:26 -05:00
|
|
|
|
unless clone_repo(ee_repo_url, ee_repo_dir)
|
|
|
|
|
# Fallback to using the canonical EE if there is no forked EE
|
|
|
|
|
clone_repo(CANONICAL_EE_REPO_URL, ee_repo_dir)
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
def clone_repo(url, dir)
|
|
|
|
|
_, status = step(
|
|
|
|
|
"Cloning #{url} into #{dir}",
|
|
|
|
|
%W[git clone --branch master --single-branch --depth=200 #{url} #{dir}]
|
|
|
|
|
)
|
|
|
|
|
status.zero?
|
|
|
|
|
end
|
|
|
|
|
|
2016-10-28 12:13:59 -04:00
|
|
|
|
def ensure_patches_dir
|
|
|
|
|
FileUtils.mkdir_p(patches_dir)
|
|
|
|
|
end
|
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
def generate_patch(branch:, patch_path:, branch_remote:, master_remote:)
|
2016-10-28 12:13:59 -04:00
|
|
|
|
FileUtils.rm(patch_path, force: true)
|
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
find_merge_base_with_master(branch: branch, branch_remote: branch_remote, master_remote: master_remote)
|
2016-10-28 12:13:59 -04:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
step(
|
2018-03-05 11:24:26 -05:00
|
|
|
|
"Generating the patch against #{master_remote}/master in #{patch_path}",
|
|
|
|
|
%W[git diff --binary #{master_remote}/master...#{branch_remote}/#{branch}]
|
2017-02-23 04:09:55 -05:00
|
|
|
|
) do |output, status|
|
2017-06-13 05:02:33 -04:00
|
|
|
|
throw(:halt_check, :ko) unless status.zero?
|
|
|
|
|
|
|
|
|
|
File.write(patch_path, output)
|
|
|
|
|
|
|
|
|
|
throw(:halt_check, :ko) unless File.exist?(patch_path)
|
2017-02-23 04:09:55 -05:00
|
|
|
|
end
|
2016-10-28 12:13:59 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ce_branch_compat_check!
|
2017-11-22 17:30:31 -05:00
|
|
|
|
if check_patch(ce_patch_full_path).zero?
|
2016-10-28 12:13:59 -04:00
|
|
|
|
puts applies_cleanly_msg(ce_branch)
|
2016-10-17 12:52:14 -04:00
|
|
|
|
throw(:halt_check)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ee_branch_presence_check!
|
2018-03-05 11:24:26 -05:00
|
|
|
|
ee_remotes.keys.each do |remote|
|
2018-07-10 10:47:15 -04:00
|
|
|
|
output, _ = step(
|
|
|
|
|
"Searching #{remote}",
|
|
|
|
|
%W[git ls-remote #{remote} *#{minimal_ee_branch_name}*])
|
2018-03-05 11:24:26 -05:00
|
|
|
|
|
2018-07-10 10:47:15 -04:00
|
|
|
|
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
|
2017-02-23 04:09:55 -05:00
|
|
|
|
end
|
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
puts
|
|
|
|
|
puts ce_branch_doesnt_apply_cleanly_and_no_ee_branch_msg
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
throw(:halt_check, :ko)
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ee_branch_compat_check!
|
2017-11-22 17:30:31 -05:00
|
|
|
|
unless check_patch(ee_patch_full_path).zero?
|
2016-10-17 12:52:14 -04:00
|
|
|
|
puts
|
|
|
|
|
puts ee_branch_doesnt_apply_cleanly_msg
|
|
|
|
|
|
|
|
|
|
throw(:halt_check, :ko)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
puts
|
2017-03-27 08:34:56 -04:00
|
|
|
|
puts applies_cleanly_msg(ee_branch_found)
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
2017-11-22 17:30:31 -05:00
|
|
|
|
def check_patch(patch_path)
|
2016-10-28 12:13:59 -04:00
|
|
|
|
step("Checking out master", %w[git checkout master])
|
2017-11-22 17:30:31 -05:00
|
|
|
|
step("Resetting to latest master", %w[git reset --hard canonical-ee/master])
|
2017-02-23 04:09:55 -05:00
|
|
|
|
step(
|
|
|
|
|
"Checking if #{patch_path} applies cleanly to EE/master",
|
2017-06-13 05:02:33 -04:00
|
|
|
|
# Don't use --check here because it can result in a 0-exit status even
|
|
|
|
|
# though the patch doesn't apply cleanly, e.g.:
|
|
|
|
|
# > git apply --check --3way foo.patch
|
|
|
|
|
# error: patch failed: lib/gitlab/ee_compat_check.rb:74
|
|
|
|
|
# Falling back to three-way merge...
|
|
|
|
|
# Applied patch to 'lib/gitlab/ee_compat_check.rb' with conflicts.
|
|
|
|
|
# > echo $?
|
|
|
|
|
# 0
|
|
|
|
|
%W[git apply --3way #{patch_path}]
|
2017-02-23 04:09:55 -05:00
|
|
|
|
) do |output, status|
|
2017-05-16 09:34:04 -04:00
|
|
|
|
puts output
|
2018-01-11 11:34:01 -05:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
unless status.zero?
|
|
|
|
|
@failed_files = output.lines.reduce([]) do |memo, line|
|
|
|
|
|
if line.start_with?('error: patch failed:')
|
|
|
|
|
file = line.sub(/\Aerror: patch failed: /, '')
|
|
|
|
|
memo << file unless file =~ IGNORED_FILES_REGEX
|
|
|
|
|
end
|
2018-01-11 11:34:01 -05:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
memo
|
2016-10-28 12:13:59 -04:00
|
|
|
|
end
|
2017-02-23 04:09:55 -05:00
|
|
|
|
|
|
|
|
|
status = 0 if failed_files.empty?
|
2016-10-28 12:13:59 -04:00
|
|
|
|
end
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2017-06-13 05:02:33 -04:00
|
|
|
|
command(%w[git reset --hard])
|
2017-02-23 04:09:55 -05:00
|
|
|
|
status
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def delete_ee_branches_locally!
|
|
|
|
|
command(%w[git checkout master])
|
|
|
|
|
command(%W[git branch --delete --force #{ee_branch_prefix}])
|
|
|
|
|
command(%W[git branch --delete --force #{ee_branch_suffix}])
|
|
|
|
|
end
|
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
def merge_base_found?(branch:, branch_remote:, master_remote:)
|
2017-02-23 04:09:55 -05:00
|
|
|
|
step(
|
2017-11-20 11:16:45 -05:00
|
|
|
|
"Finding merge base with #{master_remote}/master",
|
2018-03-05 11:24:26 -05:00
|
|
|
|
%W[git merge-base #{master_remote}/master #{branch_remote}/#{branch}]
|
2017-02-23 04:09:55 -05:00
|
|
|
|
) do |output, status|
|
|
|
|
|
if status.zero?
|
|
|
|
|
puts "Merge base was found: #{output}"
|
|
|
|
|
true
|
2016-10-28 12:13:59 -04:00
|
|
|
|
end
|
|
|
|
|
end
|
2017-02-23 04:09:55 -05:00
|
|
|
|
end
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
def find_merge_base_with_master(branch:, branch_remote:, master_remote:)
|
2017-02-23 04:09:55 -05:00
|
|
|
|
# Start with (Math.exp(3).to_i = 20) until (Math.exp(6).to_i = 403)
|
|
|
|
|
# In total we go (20 + 54 + 148 + 403 = 625) commits deeper
|
|
|
|
|
depth = 20
|
|
|
|
|
success =
|
|
|
|
|
(3..6).any? do |factor|
|
|
|
|
|
depth += Math.exp(factor).to_i
|
|
|
|
|
# Repository is initially cloned with a depth of 20 so we need to fetch
|
|
|
|
|
# deeper in the case the branch has more than 20 commits on top of master
|
2018-03-05 11:24:26 -05:00
|
|
|
|
fetch(branch: branch, depth: depth, remote: branch_remote)
|
2017-11-20 11:16:45 -05:00
|
|
|
|
fetch(branch: 'master', depth: depth, remote: master_remote)
|
2017-02-23 04:09:55 -05:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
merge_base_found?(branch: branch, branch_remote: branch_remote, master_remote: master_remote)
|
2017-02-23 04:09:55 -05:00
|
|
|
|
end
|
|
|
|
|
|
2017-11-20 11:16:45 -05:00
|
|
|
|
raise "\n#{branch} is too far behind #{master_remote}/master, please rebase it!\n" unless success
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
2017-11-15 09:18:07 -05:00
|
|
|
|
def fetch(branch:, depth:, remote: 'origin')
|
2017-02-23 04:09:55 -05:00
|
|
|
|
step(
|
|
|
|
|
"Fetching deeper...",
|
2017-11-20 11:16:45 -05:00
|
|
|
|
%W[git fetch --depth=#{depth} --prune #{remote} +refs/heads/#{branch}:refs/remotes/#{remote}/#{branch}]
|
2017-02-23 04:09:55 -05:00
|
|
|
|
) do |output, status|
|
|
|
|
|
raise "Fetch failed: #{output}" unless status.zero?
|
|
|
|
|
end
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ce_patch_name
|
2016-11-22 13:13:41 -05:00
|
|
|
|
@ce_patch_name ||= patch_name_from_branch(ce_branch)
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ce_patch_full_path
|
2016-10-28 12:13:59 -04:00
|
|
|
|
@ce_patch_full_path ||= patches_dir.join(ce_patch_name)
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
def ee_branch_suffix
|
|
|
|
|
@ee_branch_suffix ||= "#{ce_branch}-ee"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ee_branch_prefix
|
|
|
|
|
@ee_branch_prefix ||= "ee-#{ce_branch}"
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ee_patch_name
|
2017-03-27 08:34:56 -04:00
|
|
|
|
@ee_patch_name ||= patch_name_from_branch(ee_branch_found)
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ee_patch_full_path
|
2016-10-28 12:13:59 -04:00
|
|
|
|
@ee_patch_full_path ||= patches_dir.join(ee_patch_name)
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
2018-07-10 10:47:15 -04:00
|
|
|
|
def minimal_ee_branch_name
|
|
|
|
|
@minimal_ee_branch_name ||= ce_branch.sub(/(\Ace\-|\-ce\z)/, '')
|
|
|
|
|
end
|
|
|
|
|
|
2016-11-22 13:13:41 -05:00
|
|
|
|
def patch_name_from_branch(branch_name)
|
2018-10-22 21:15:07 -04:00
|
|
|
|
"#{branch_name.parameterize}.patch"
|
2016-11-22 13:13:41 -05:00
|
|
|
|
end
|
|
|
|
|
|
2017-07-19 05:11:26 -04:00
|
|
|
|
def patch_url
|
2017-10-31 09:24:45 -04:00
|
|
|
|
"#{ce_project_url}/-/jobs/#{job_id}/artifacts/raw/ee_compat_check/patches/#{ce_patch_name}"
|
2017-07-19 05:11:26 -04:00
|
|
|
|
end
|
|
|
|
|
|
2016-10-17 12:52:14 -04:00
|
|
|
|
def step(desc, cmd = nil)
|
|
|
|
|
puts "\n=> #{desc}\n"
|
|
|
|
|
|
|
|
|
|
if cmd
|
2016-10-28 12:13:59 -04:00
|
|
|
|
start = Time.now
|
2016-10-17 12:52:14 -04:00
|
|
|
|
puts "\n$ #{cmd.join(' ')}"
|
2017-02-23 04:09:55 -05:00
|
|
|
|
|
|
|
|
|
output, status = command(cmd)
|
|
|
|
|
puts "\n==> Finished in #{Time.now - start} seconds"
|
|
|
|
|
|
|
|
|
|
if block_given?
|
|
|
|
|
yield(output, status)
|
|
|
|
|
else
|
|
|
|
|
[output, status]
|
|
|
|
|
end
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def command(cmd)
|
2017-02-23 04:09:55 -05:00
|
|
|
|
Gitlab::Popen.popen(cmd)
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
# We're "re-creating" the repo URL because ENV['CI_REPOSITORY_URL'] contains
|
|
|
|
|
# redacted credentials (e.g. "***:****") which are useless in instructions
|
|
|
|
|
# the job gives.
|
|
|
|
|
def ce_public_repo_url
|
|
|
|
|
"#{ce_project_url}.git"
|
|
|
|
|
end
|
|
|
|
|
|
2016-10-28 12:13:59 -04:00
|
|
|
|
def applies_cleanly_msg(branch)
|
2017-03-23 14:15:56 -04:00
|
|
|
|
%Q{
|
|
|
|
|
#{PLEASE_READ_THIS_BANNER}
|
2016-10-17 12:52:14 -04:00
|
|
|
|
🎉 Congratulations!! 🎉
|
|
|
|
|
|
2017-03-23 14:15:56 -04:00
|
|
|
|
The `#{branch}` branch applies cleanly to EE/master!
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
Much ❤️! For more information, see
|
2017-12-05 11:49:49 -05:00
|
|
|
|
https://docs.gitlab.com/ce/development/automatic_ce_ee_merge.html
|
2017-03-23 14:15:56 -04:00
|
|
|
|
#{THANKS_FOR_READING_BANNER}
|
|
|
|
|
}
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ce_branch_doesnt_apply_cleanly_and_no_ee_branch_msg
|
2018-03-05 11:24:26 -05:00
|
|
|
|
ee_repos = ee_remotes.values.uniq
|
|
|
|
|
|
2017-03-23 14:15:56 -04:00
|
|
|
|
%Q{
|
|
|
|
|
#{PLEASE_READ_THIS_BANNER}
|
2016-10-17 12:52:14 -04:00
|
|
|
|
💥 Oh no! 💥
|
|
|
|
|
|
2017-03-23 14:15:56 -04:00
|
|
|
|
The `#{ce_branch}` branch does not apply cleanly to the current
|
2017-02-23 04:09:55 -05:00
|
|
|
|
EE/master, and no `#{ee_branch_prefix}` or `#{ee_branch_suffix}` branch
|
2018-03-05 11:24:26 -05:00
|
|
|
|
was found in #{ee_repos.join(' nor in ')}.
|
2017-02-23 04:09:55 -05:00
|
|
|
|
|
2017-09-14 14:12:36 -04:00
|
|
|
|
If you're a community contributor, don't worry, someone from
|
|
|
|
|
GitLab Inc. will take care of this, and you don't have to do anything.
|
|
|
|
|
If you're willing to help, and are ok to contribute to EE as well,
|
|
|
|
|
you're welcome to help. You could follow the instructions below.
|
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
#{conflicting_files_msg}
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
We advise you to create a `#{ee_branch_prefix}` or `#{ee_branch_suffix}`
|
2017-03-23 14:15:56 -04:00
|
|
|
|
branch that includes changes from `#{ce_branch}` but also specific changes
|
2017-02-23 04:09:55 -05:00
|
|
|
|
than can be applied cleanly to EE/master. In some cases, the conflicts
|
|
|
|
|
are trivial and you can ignore the warning from this job. As always,
|
2017-09-14 14:12:36 -04:00
|
|
|
|
use your best judgement!
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
|
|
|
|
There are different ways to create such branch:
|
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
1. Create a new branch from master and cherry-pick your CE commits
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
|
|
|
|
# In the EE repo
|
2018-03-05 11:24:26 -05:00
|
|
|
|
$ git fetch #{CANONICAL_EE_REPO_URL} master
|
2017-11-20 11:16:45 -05:00
|
|
|
|
$ git checkout -b #{ee_branch_prefix} FETCH_HEAD
|
2018-03-05 11:24:26 -05:00
|
|
|
|
$ git fetch #{ce_public_repo_url} #{ce_branch}
|
2017-02-23 04:09:55 -05:00
|
|
|
|
$ git cherry-pick SHA # Repeat for all the commits you want to pick
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
Note: You can squash the `#{ce_branch}` commits into a single "Port of #{ce_branch} to EE" commit.
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
2. Apply your branch's patch to EE
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
|
|
|
|
# In the EE repo
|
2018-03-05 11:24:26 -05:00
|
|
|
|
$ git fetch #{CANONICAL_EE_REPO_URL} master
|
2017-11-20 11:16:45 -05:00
|
|
|
|
$ git checkout -b #{ee_branch_prefix} FETCH_HEAD
|
|
|
|
|
$ wget #{patch_url} && git apply --3way #{ce_patch_name}
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
At this point you might have conflicts such as:
|
|
|
|
|
|
|
|
|
|
error: patch failed: lib/gitlab/ee_compat_check.rb:5
|
|
|
|
|
Falling back to three-way merge...
|
|
|
|
|
Applied patch to 'lib/gitlab/ee_compat_check.rb' with conflicts.
|
|
|
|
|
U lib/gitlab/ee_compat_check.rb
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
Resolve them, stage the changes and commit them.
|
2017-05-16 09:34:04 -04:00
|
|
|
|
|
2017-05-16 09:04:52 -04:00
|
|
|
|
If the patch couldn't be applied cleanly, use the following command:
|
2017-05-16 09:34:04 -04:00
|
|
|
|
|
2017-05-16 09:04:52 -04:00
|
|
|
|
# In the EE repo
|
2017-07-19 05:11:26 -04:00
|
|
|
|
$ git apply --reject #{ce_patch_name}
|
2017-05-16 09:34:04 -04:00
|
|
|
|
|
2017-05-16 09:04:52 -04:00
|
|
|
|
This option makes git apply the parts of the patch that are applicable,
|
|
|
|
|
and leave the rejected hunks in corresponding `.rej` files.
|
|
|
|
|
You can then resolve the conflicts highlighted in `.rej` by
|
|
|
|
|
manually applying the correct diff from the `.rej` file to the file with conflicts.
|
|
|
|
|
When finished, you can delete the `.rej` files and commit your changes.
|
2017-02-23 04:09:55 -05:00
|
|
|
|
|
|
|
|
|
⚠️ Don't forget to push your branch to gitlab-ee:
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
|
|
|
|
# In the EE repo
|
2017-02-23 04:09:55 -05:00
|
|
|
|
$ git push origin #{ee_branch_prefix}
|
|
|
|
|
|
2017-07-07 10:46:36 -04:00
|
|
|
|
⚠️ Also, don't forget to create a new merge request on gitlab-ee and
|
2017-02-23 04:09:55 -05:00
|
|
|
|
cross-link it with the CE merge request.
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
Once this is done, you can retry this failed job, and it should pass.
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
#{STAY_STRONG_LINK_TO_DOCS}
|
2017-03-23 14:15:56 -04:00
|
|
|
|
#{THANKS_FOR_READING_BANNER}
|
|
|
|
|
}
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ee_branch_doesnt_apply_cleanly_msg
|
2017-03-23 14:15:56 -04:00
|
|
|
|
%Q{
|
|
|
|
|
#{PLEASE_READ_THIS_BANNER}
|
2016-10-17 12:52:14 -04:00
|
|
|
|
💥 Oh no! 💥
|
|
|
|
|
|
2017-03-23 14:15:56 -04:00
|
|
|
|
The `#{ce_branch}` does not apply cleanly to the current EE/master, and
|
2017-02-23 04:09:55 -05:00
|
|
|
|
even though a `#{ee_branch_found}` branch
|
2018-03-05 11:24:26 -05:00
|
|
|
|
exists in #{ee_repo_url}, it does not apply cleanly either to
|
2017-02-23 04:09:55 -05:00
|
|
|
|
EE/master!
|
|
|
|
|
|
|
|
|
|
#{conflicting_files_msg}
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2017-02-23 04:09:55 -05:00
|
|
|
|
Please update the `#{ee_branch_found}`, push it again to gitlab-ee, and
|
2018-03-05 11:24:26 -05:00
|
|
|
|
retry this job.
|
2016-10-17 12:52:14 -04:00
|
|
|
|
|
2018-03-05 11:24:26 -05:00
|
|
|
|
#{STAY_STRONG_LINK_TO_DOCS}
|
2017-03-23 14:15:56 -04:00
|
|
|
|
#{THANKS_FOR_READING_BANNER}
|
|
|
|
|
}
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
2017-02-23 04:09:55 -05:00
|
|
|
|
|
|
|
|
|
def conflicting_files_msg
|
2018-10-22 21:15:07 -04:00
|
|
|
|
header = "The conflicts detected were as follows:\n"
|
|
|
|
|
separator = "\n - "
|
|
|
|
|
failed_items = failed_files.join(separator)
|
|
|
|
|
|
|
|
|
|
"#{header}#{separator}#{failed_items}"
|
2017-02-23 04:09:55 -05:00
|
|
|
|
end
|
2016-10-17 12:52:14 -04:00
|
|
|
|
end
|
|
|
|
|
end
|