Skip to content

localrepo: Allow updating default branch via git-update-ref(1)

To update the default branch of a repository, we simply modify the HEAD file of the repository. To do this in Praefect, we create a HEAD.lock file and vote on the content of the file. This works because we use the filesystem backend and would break with the upcoming reftable backend.

To solve this issue, we introduced 'symref-update' command to Git. This feature is yet to be merged and tagged in an official Git release, but we can already start adding the required code and tests in our CI.

We first introduce updateref.SymrefUpdate to update symrefs. Using this, we introduce setDefaultBranchWithUpdateRef in the localrepo package. Now when the Git version is set to the experimental version (v99.99.99), we will use this function over the existing function which has been renamed to setDefaultBranchManually.

While earlier, we manually voted on the contents of the HEAD.lock file for Praefect. Now we simply rely on the existing architecture of the reference-transaction hook to capture this detail for us. This means existing tests will not work for the newly introduced code since they don't instantiate the reference transaction hook, so we introduce new tests for the same. The tests would cause an import loop so we add them to 'localrepo_test' package to avoid the looping.

Eventually this flow would be made default, and we can clear up all this messy glue code.

Closes #5839 (closed)

Edited by Karthik Nayak

Merge request reports