New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent deletion of default branch #1827
Conversation
@@ -0,0 +1,2 @@ | |||
- type: Changed | |||
description: The default branch of a repository cannot be deleted ([#1827](https://github.com/scm-manager/scm-manager/pull/1827)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: The default branch of a repository cannot be deleted ([#1827](https://github.com/scm-manager/scm-manager/pull/1827)) | |
description: The default branch of a git repository cannot be deleted ([#1827](https://github.com/scm-manager/scm-manager/pull/1827)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work for hg, too (though currently it doesn't)
} | ||
|
||
gitHeadModifier.ensure(repository, newDefaultBranch); | ||
storeProvider.get(repository).get().setDefaultBranch(newDefaultBranch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the reference of the config does not persist the changes nor triggers update events. You have to call the set method of the store.
Kudos, SonarCloud Quality Gate passed! |
Proposed changes
Adds a pre receive repository hook that prevents the deletion of the default branch.
Mirrored repositories will change their default branches to another branch, when it is deleted.
Your checklist for this pull request
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Contributor:
gradle/changelog
or CHANGELOG.md is updated for pluginsReviewer:
Checklist for branch merge request (not required for forks)