git-mirror
git-mirror copied to clipboard
Default branch deletion
I'm using Git Mirror to synchronize repositories from GitHub to GitLab.
The following scenario will make the synchronization fail:
- Default branch is
master
on both GitHub and GitLab - Default branch change from
master
todev
on GitHub - Branch
master
is deleted on GitHub - Git Mirror execution
=> synchronization fail because branch
master
cannot be deleted from GitLab as it's the current default.
Only solution I can think of is that Git Mirror would need to be able to process this default branch information and synchronize it when it exists on both source and destination. I know that this default branch concept is not standard but it is at least available in GitHub and GitLab.
The goal of git-mirror is to sync 1:1 between git repos. I don't think it should try to map between branches, or at least that would need a more generic solution than just default braches.
But in your case where the default branch changed, isn't this just an issue that the branch is protected on gitlab side? If yes than think #31 would solve your issue. Or is it really because it is marked as the default branch?
Even if I remove the protection on the GitLab master
branch, issue will persist as GitLab reject deletion of the default branch:
START 0/1 [2020-09-08 17:18:16.943705251 +02:00]: https://github.com/amottier/test-git-mirror.git -> [email protected]:antoinemottier/test-git-mirror-gitlab.git
END(FAIL) 0/1 [2020-09-08 17:18:20.526362820 +02:00]: https://github.com/amottier/test-git-mirror.git -> [email protected]:antoinemottier/test-git-mirror-gitlab.git (Command "git" "push" "--mirror" "[email protected]:antoinemottier/test-git-mirror-gitlab.git" failed with exit code: 1, Stderr: remote: GitLab: The default branch of a project cannot be deleted.
To gitlab.com:antoinemottier/test-git-mirror-gitlab.git
! [remote rejected] master (pre-receive hook declined)
! [remote rejected] dev -> dev (pre-receive hook declined)
error: failed to push some refs to 'gitlab.com:antoinemottier/test-git-mirror-gitlab.git'
)
So removing the protection is I think only one part of the issue (and I agree that #31 would solve this part of the issue), the second being how to update the default branch setting in GitLab.
I'm not looking for a solution to synchronize this "default branch" information available in GitHub: Settings → Branches → Default branch
and in GitLab: Settings → Repository → Default Branch
.