Skip to content
Snippets Groups Projects

Change the approach to check if patches apply cleanly

Merged Rémy Coutable requested to merge 23372-fix-ce-to-ee-merge-check-task into master
All threads resolved!
Compare and Show latest version
1 file
+ 14
10
Compare changes
  • Side-by-side
  • Inline
+ 14
10
@@ -19,7 +19,7 @@ namespace :gitlab do
cmd = %W[git clone --branch master --single-branch --depth 1 #{ee_repo} #{ee_dir}]
step("Cloning #{ee_repo} into #{ee_dir}", cmd)
command(%W[git fetch origin master])
step("Fetching origin/master", %w[git fetch origin master])
cmd = %W[git format-patch origin/master --stdout > ./#{ee_dir}/#{ce_patch_name}]
step("Generating the patch against master for #{ce_branch}", cmd)
@@ -30,10 +30,13 @@ namespace :gitlab do
cmd = %W[git apply --check #{ce_patch_name}]
status = step("Checking if #{ce_patch_name} applies cleanly to EE/master", cmd)
puts ce_applies_cleanly_msg(ce_branch) if status.zero?
if status.zero?
puts ce_applies_cleanly_msg(ce_branch)
clean_dir_and_exit(ee_dir)
end
# Check if the <branch>-ee branch exists...
command(%W[git fetch origin #{ee_branch}])
step("Fetching origin/#{ee_branch}", %W[git fetch origin #{ee_branch}])
cmd = %W[git checkout #{ee_branch}]
status = step("Checking out the #{ee_branch} branch", cmd)
@@ -48,7 +51,7 @@ namespace :gitlab do
ee_branch: ee_branch
)
exit 1
clean_dir_and_exit(ee_dir, 1)
end
# Check if the EE-branch patch applies cleanly to EE/master...
@@ -66,19 +69,20 @@ namespace :gitlab do
ee_branch: ee_branch
)
exit 2
clean_dir_and_exit(ee_dir, 2)
end
puts
puts ee_applies_cleanly_msg(ee_branch: ee_branch)
end
clean_dir(ee_dir)
exit 0
clean_dir_and_exit(ee_dir)
end
def clean_dir(dir)
def clean_dir_and_exit(dir, status = 0)
FileUtils.rm_rf(dir)
exit status
end
def step(desc, cmd = nil)
@@ -112,7 +116,7 @@ namespace :gitlab do
def ce_branch_doesnt_apply_cleanly_and_no_ee_branch_msg(ce_repo:, ce_branch:, ee_repo:, ee_branch:)
<<-MSG.strip_heredoc
=================================================================
💥 Oh no! 💥
💥 Oh no! 💥
The #{ce_branch} branch does not apply cleanly to the current
EE/master, and no #{ee_branch} branch was found in the EE repository.
@@ -150,7 +154,7 @@ namespace :gitlab do
def ee_branch_doesnt_apply_cleanly_msg(ce_branch:, ee_repo:, ee_branch:)
<<-MSG.strip_heredoc
=================================================================
💥 Oh no! 💥
💥 Oh no! 💥
The #{ce_branch} does not apply cleanly to the current
EE/master, and even though a #{ee_branch} branch exists in the EE
Loading