Skip to content

Fix push rules on Git 2.11

username-removed-128633 requested to merge 1736-fix-push-rules-git-2-11 into master

What does this MR do?

The problem was described in https://gitlab.com/gitlab-org/gitlab-ee/issues/1736#note_24262662.

An additional thing that I fixed is that once we found the new commits (via Gitlab::Popen.popen in Repository#new_commits), we try to instantiate commit objects for the returned SHAs. The issue was that those commits are still in the quarantine directories (GIT_OBJECT_DIRECTORY, and GIT_ALTERNATE_OBJECT_DIRECTORIES) at this point: we needed a way to tell the Rugged repo to look for these SHAs in these directories as well.

After some digging through libgit2 and Rugged, I found out that Rugged::Repository#new actually accepts an alternate keyword param just for that!

The final solution is thus to set environment variables in /api/v3/internal/allowed from GIT_OBJECT_DIRECTORY, and GIT_ALTERNATE_OBJECT_DIRECTORIES passed from gitlab-shell and use those variable when instantiating the Rugged repo in Rugged::Repository#new.

Are there points in the code the reviewer needs to double check?

I've removed the passing of env to Gitlab::GitAccess#new since these are already available from the subprocess spawned by Gitlab::Popen.popen.

Why was this MR needed?

To fix push-rules and other commit checks that happens in pre-receive hooks.

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #1736 (closed)

Merge request reports