-
Notifications
You must be signed in to change notification settings - Fork 5
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
Delete Branch After Merge #138
Comments
There's a repository setting that enables this behavior: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-the-automatic-deletion-of-branches |
@pi-alexander-popel can it be done automatically using some gh command option when we are merging? it is kinda tedious to switch on every repo... |
No such option, unfortunately. |
When we have time let's write a script that'd utilize |
Here's the PowerShell script: $org = '51Degrees'
$list = gh repo list 51Degrees --no-archived --limit 256 --json name --jq '.[].name'
Write-Host -Separator "`n" $list
Write-Host '---------'
$confirm = Read-Host 'The repositories above will have the "Delete branch on merge" setting enabled. Continue [y/N]'
if ($confirm -like 'y*') {
foreach ($repo in $list) {
gh repo edit $org/$repo --delete-branch-on-merge
}
}
|
After the Nightly PRs to Main workflow merges a PR, the source branch should be deleted by default.
This keeps the repo tidy by removing branches which are no longer needed.
For PRs from external forks, the branch should not be deleted, as it not a 51Degrees repo (and the delete would fail anyway)
The text was updated successfully, but these errors were encountered: