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
2 files
+ 36
304
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 36
33
@@ -14,32 +14,38 @@ namespace :gitlab do
ee_patch_name = "#{ee_branch}.patch"
ee_dir = 'gitlab-ee-merge-check'
clean_dir(ee_dir)
cmd = %W[git clone --branch master --single-branch --depth 1 #{ee_repo} #{ee_dir}]
step("Cloning #{ee_repo} into #{ee_dir}", cmd)
if Dir.exists?(ee_repo)
step("#{ee_dir} already exists")
else
cmd = %W[git clone --branch master --single-branch --depth 1 #{ee_repo} #{ee_dir}]
step("Cloning #{ee_repo} into #{ee_dir}", cmd)
end
FileUtils.rm("./#{ee_dir}/#{ce_patch_name}", force: true)
step("Fetching origin/master", %w[git fetch origin master])
cmd = %W[git format-patch origin/master --stdout > ./#{ee_dir}/#{ce_patch_name}]
cmd = %W[git format-patch FETCH_HEAD --stdout > ./#{ee_dir}/#{ce_patch_name}]
step("Generating the patch against master for #{ce_branch}", cmd)
Dir.chdir(ee_dir) do
step("In the #{run_command(%w[pwd]).chomp} directory")
step("Pulling latest master", %w[git pull --ff-only origin master])
# Check if the CE-branch patch applies cleanly to EE/master...
cmd = %W[git apply --check #{ce_patch_name}]
status = step("Checking if #{ce_patch_name} applies cleanly to EE/master", cmd)
if status.zero?
puts ce_applies_cleanly_msg(ce_branch)
clean_dir_and_exit(ee_dir)
exit 0
end
# Check if the <branch>-ee branch exists...
step("Fetching origin/#{ee_branch}", %W[git fetch origin #{ee_branch}])
status = 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)
# cmd = %W[git checkout -b #{ee_branch} FETCH_HEAD]
# status = step("Checking out the #{ee_branch} branch", cmd)
# The <branch>-ee doesn't exist
unless status.zero?
@@ -51,40 +57,37 @@ namespace :gitlab do
ee_branch: ee_branch
)
clean_dir_and_exit(ee_dir, 1)
exit 1
end
# Check if the EE-branch patch applies cleanly to EE/master...
# Does it really make sense? Won't an EE patch always apply to EE/master???????
command(%W[git format-patch origin/master --stdout > #{ee_patch_name}])
cmd = %W[git apply --check #{ee_patch_name}]
status = step("Checking if #{ee_patch_name} applies cleanly to EE/master", cmd)
# The <branch>-ee cannot be merged cleanly to EE/master...
unless status.zero?
puts
puts ee_branch_doesnt_apply_cleanly_msg(
ce_branch: ce_branch,
ee_repo: ee_repo,
ee_branch: ee_branch
)
clean_dir_and_exit(ee_dir, 2)
end
# # Check if the EE-branch patch applies cleanly to EE/master...
# # Does it really make sense? Won't an EE patch always apply to EE/master???????
# FileUtils.rm(ee_patch_name, force: true)
# command(%W[git format-patch origin/master --stdout > #{ee_patch_name}])
# cmd = %W[git apply --check #{ee_patch_name}]
# status = step("Checking if #{ee_patch_name} applies cleanly to EE/master", cmd)
#
# # The <branch>-ee cannot be merged cleanly to EE/master...
# unless status.zero?
# puts
# puts ee_branch_doesnt_apply_cleanly_msg(
# ce_branch: ce_branch,
# ee_repo: ee_repo,
# ee_branch: ee_branch
# )
#
# clean_dir_and_exit(ee_dir, 2)
# end
puts
puts ee_applies_cleanly_msg(ee_branch: ee_branch)
end
clean_dir_and_exit(ee_dir)
end
def clean_dir(dir)
FileUtils.rm_rf(dir)
exit 0
end
def clean_dir_and_exit(dir, status = 0)
clean_dir(dir)
FileUtils.rm_rf(dir)
exit status
end
@@ -93,7 +96,7 @@ namespace :gitlab do
puts "\n=> #{desc}\n"
if cmd
puts "\n==> #{cmd.join(' ')}"
puts "\n$ #{cmd.join(' ')}"
command(cmd)
end
end
Loading