stable

Clone or download

Read-only

Set the default branch to 'main' when creating a new repository

The first attempt done in git #tuleap/stable/dffffec067b171d2dbfd80c51c2f80da98ffb8e2 resulted in broken Git repositories with the default global Git settings. The issue was caused by the fact that while repositories are created by the gitolite user, the change of the default branch was set done as the codendiadm user which resulted in a file owned and only readable by it. To avoid this issue, the initial default branch modification when the repo is created is now done by the gitolite user to avoid issues. To test, do not forget to deploy the new sudoers config file. It is possible to fix the repositories that were broken by the initial implementation with the following command: ``` # find /var/lib/gitolite/repositories/ -user codendiadm -name 'HEAD' -type f -exec sh -c 'chown gitolite:gitolite {} && chmod 0660 {}' \; ``` Part of request #13356: Allow to change the default branch Change-Id: I3de44e4445a2df39b58488a5706492efa81222ee

Modified Files

Name
A plugins/git/bin/change-default-branch.php +39 −0 Go to diff View file
M plugins/git/composer.json +1 −1 Go to diff View file
A plugins/git/etc/sudoers.d/git-change-default-branch +3 −0 Go to diff View file
M plugins/git/hooks/post-receive.php +1 −1 Go to diff View file
A plugins/git/include/DefaultBranch/CannotExecuteDefaultBranchUpdateException.php +34 −0 Go to diff View file
M plugins/git/include/DefaultBranch/DefaultBranchPostReceiveUpdater.php +8 −1 Go to diff View file
A plugins/git/include/DefaultBranch/DefaultBranchUpdateExecutor.php +32 −0 Go to diff View file
A plugins/git/include/DefaultBranch/DefaultBranchUpdateExecutorAsGitoliteUser.php +42 −0 Go to diff View file
M plugins/git/include/DefaultBranch/DefaultBranchUpdater.php +8 −1 Go to diff View file
M plugins/git/include/REST/v1/RepositoryResource.class.php +2 −1 Go to diff View file
M plugins/git/include/SystemEvents/SystemEvent_GIT_REPO_UPDATE.class.php +12 −7 Go to diff View file
M plugins/git/include/gitPlugin.php +4 −2 Go to diff View file
A plugins/git/tests/rest/setup.sh +6 −0 Go to diff View file
M plugins/git/tests/unit/DefaultBranch/DefaultBranchPostReceiveUpdaterTest.php +11 −5 Go to diff View file
A plugins/git/tests/unit/DefaultBranch/DefaultBranchUpdateTestExecutor.php +55 −0 Go to diff View file
M plugins/git/tests/unit/DefaultBranch/DefaultBranchUpdaterTest.php +22 −6 Go to diff View file
M plugins/git/tests/unit/GitGerritRouteTest.php +2 −4 Go to diff View file
M plugins/git/tests/unit/SystemEvents/SystemEvent_GIT_REPO_UPDATETest.php +46 −5 Go to diff View file
M tools/rpm/tuleap.rhel7.spec +2 −0 Go to diff View file