Skip to content

Repository creation: allow default_branch as an argument to be passed to Gitaly

John Cai requested to merge jc-create-repository-default-branch into master

What does this MR do and why?

Allow gitaly create_repository to take a default branch argument

Currently when rails wants to ensure a default branch name, it will call the Gitaly WriteRef RPC to manually change it. If this call happens in a racy way eg: it gets called when another RPC is operating on the same repository, it will fail. Rather than do this, the Gitaly CreateRepository RPC has a default_branch parameter.

Allow rails callers to set this value. If it is not provided, then the default branch in Gitaly will be used, which is main.

This will allow us to move away from the pattern we find in snippets where we change the head to the default branch after the fact. This has caused issues when the call to change the default branch (through the WriteRef RPC in Gitaly) is racy and ends up failing.

See #353935 (closed) for context

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by John Cai

Merge request reports

Loading