Skip to content

Improve `Gitlab::EeCompatCheck` by using the `git apply --3way` flag

What does this MR do?

See commit message. /cc @DouweM @zj

I've verified that with the patch from !9408 (merged):

Without this change:

ruby 2.3.3p222 in gitlab/ on master 
› git apply --check zj-fix-slash-command-labels.patch 

error: patch failed: lib/gitlab/chat_commands/presenters/issue_base.rb:32
error: lib/gitlab/chat_commands/presenters/issue_base.rb: patch does not apply

› echo $?                                            
1

With this change:

› git apply --check --3way zj-fix-slash-command-labels.patch

error: patch failed: lib/gitlab/chat_commands/presenters/issue_base.rb:32
Falling back to three-way merge...
Applied patch to 'lib/gitlab/chat_commands/presenters/issue_base.rb' cleanly.

› echo $?
0

Why was this MR needed?

Because the ee_compat_check job sometimes report false positive due to the fact that a patch cannot be applied without a 3-way merge strategy.

The git apply --3way flag solves that:

       -3, --3way
           When the patch does not apply cleanly, fall back on 3-way merge if the patch records the identity of
           blobs it is supposed to apply to, and we have those blobs available locally, possibly leaving the
           conflict markers in the files in the working tree for the user to resolve. This option implies the
           --index option, and is incompatible with the --reject and the --cached options.

Merge request reports