GoUserMergeBranch: Merge requests fail with "Conflicts detected during merge" when squash commits used
From gitlab-com/gl-infra/production#2985 (comment 442699365):
- Enable the
gitaly_go_user_merge_branch
feature flag. - Create a repository with
.gitlab/CODEOWNERS
with* @root
(or some user). - Set the Protected Branches to this:
- Create a merge request with 2 commits.
- Click merge and be sure to click on "Squash commits".
You get:
Unchecking Squash commits
allows the merge to go through.
The problem appears to be due to a missing GL_PROTOCOL=web
to the pre-receive hook:
diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go
index 6d2f2b3e5..dc618b433 100644
--- a/internal/gitaly/service/operations/merge.go
+++ b/internal/gitaly/service/operations/merge.go
@@ -124,6 +124,7 @@ func (s *server) updateReferenceWithHooks(ctx context.Context, repo *gitalypb.Re
fmt.Sprintf("GITALY_SOCKET=" + config.GitalyInternalSocketPath()),
fmt.Sprintf("GITALY_REPO=%s", repo),
fmt.Sprintf("GITALY_TOKEN=%s", s.cfg.Auth.Token),
+ fmt.Sprintf("GL_PROTOCOL=web"),
}, gitlabshellEnv...)
transaction, err := metadata.TransactionFromContext(ctx)
This gets passed as a parameter to the /api/v4/internal/allowed
check and bypasses the CODEOWNERS
check for merge requests, causing updated_from_web?
in https://gitlab.com/gitlab-org/gitlab/blob/c89a6b4548e42ed446099c992c5359bfe34d1de2/ee/lib/ee/gitlab/checks/diff_check.rb#L23 to return true
.
Edited by Stan Hu