Skip to content

Check if remote repository is empty in UserCommitFiles Go port

Sami Hiltunen requested to merge smh-fix-user-commit-files-repo-creation into master
  • GitLab sends UserCommitFiles requests where both the target repository and start repository refer to the same local repository. Gitaly is unable to identify these cases when ran behind Praefect, as Praefect doesn't rewrite the storage of the start repository but does rewrite the storage of target repository. This leads Gitaly to perform an RPC to resolve the target branch. While this is an unnecessary RPC, this generally works fine. This becomes a problem when UserCommitFiles is creating the first branch in the repository. Looking up the branch from via the RPC fails as the branch does not yet exist. This then lead to UserCommitFiles to fail at creating the first branch in the repository.

    This commit fixes the problem in a same manner as the Ruby implementation did. It checks if the remote repository has branches, if not, it uses the locally resolved commit instead.

  • UserCommitFiles checked whether the target repository had branches using its own implementation. Now that the repository interface contains HasBranches, we should use that one instead to avoid duplicating the functionality.

Related to #3294 (closed)

Edited by Sami Hiltunen

Merge request reports