stable

Clone or download

Read-only

Update inconsistent default branch on push

For repository with a default branch that does not exist, the default branch will now be updated when something is pushed into the repository. The goal is to make sure repositories are not in somewhat broken state. This situation can happen for multiple reasons: * the default branch was deleted, this later be prevented by a pre-commit hook but exeiting repository might be affected * the repository is new but the first pushed branch is not "master" * somebody played with a `git symbolic-ref` directly in the repo 😱 * (future) race condition: the branch has been deleted between the moment we checked if the branch exists and the moment we set the new default branch When we detect an inconsistency, the new default branch is set to the oldest branch in the repository. Part of request #13356: Allow to change the default branch Change-Id: I1a8178235425ae66a8767b728ab0e55cd1ff982a

Modified Files

Name
M plugins/git/hooks/post-receive.php +2 −1 Go to diff View file
A plugins/git/include/DefaultBranch/DefaultBranchPostReceiveUpdater.php +44 −0 Go to diff View file
M plugins/git/include/Git/Hook/PostReceive.class.php +17 −11 Go to diff View file
M plugins/git/include/Git_Exec.class.php +15 −2 Go to diff View file
A plugins/git/tests/unit/DefaultBranch/DefaultBranchPostReceiveUpdaterTest.php +66 −0 Go to diff View file
M plugins/git/tests/unit/Git/Hook/Git_Hook_PostReceive_CommonTest.php +31 −14 Go to diff View file
M plugins/git/tests/unit/Git_ExecTest.php +7 −0 Go to diff View file