Skip to content

Commit

Permalink
feat(sync-repo-settings): add a delete head branch option (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Jan 20, 2021
1 parent 1652803 commit d2aac97
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/sync-repo-settings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ branchProtectionRules:
requiresCodeOwnerReviews: true
# Require up to date branches
requiresStrictStatusChecks: true
# Automatically delete head branches after merging PRs. Defaults to `true`.
deleteBranchOnMerge: true
# List of required status check contexts that must pass for commits to be accepted to matching branches.
requiredStatusCheckContexts:
- check1
Expand Down
4 changes: 4 additions & 0 deletions packages/sync-repo-settings/src/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"description": "Whether or not PRs are merged with a merge commit on this repository.",
"type": "boolean"
},
"deleteBranchOnMerge": {
"description": "Either true to allow automatically deleting head branches when pull requests are merged, or false to prevent automatic deletion.",
"type": "boolean"
},
"branchProtectionRules": {
"description": "Branch protection rules",
"type": "array",
Expand Down
2 changes: 2 additions & 0 deletions packages/sync-repo-settings/src/sync-repo-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const repoConfigDefaults: RepoConfig = deepFreeze({
mergeCommitAllowed: false,
squashMergeAllowed: true,
rebaseMergeAllowed: true,
deleteBranchOnMerge: true,
});

const branchProtectionDefaults = deepFreeze({
Expand Down Expand Up @@ -399,6 +400,7 @@ async function updateRepoOptions(
allow_merge_commit: config.mergeCommitAllowed,
allow_rebase_merge: config.rebaseMergeAllowed,
allow_squash_merge: config.squashMergeAllowed,
delete_branch_on_merge: config.deleteBranchOnMerge,
});
logger.info(`Success updating repo options for ${repo}`);
} catch (err) {
Expand Down
4 changes: 4 additions & 0 deletions packages/sync-repo-settings/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export interface RepoConfig {
* Whether or not PRs are merged with a merge commit on this repository.
*/
mergeCommitAllowed?: boolean;
/**
* Either true to allow automatically deleting head branches when pull requests are merged, or false to prevent automatic deletion.
*/
deleteBranchOnMerge?: boolean;
/**
* Branch protection rules
*/
Expand Down
1 change: 1 addition & 0 deletions packages/sync-repo-settings/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function nockUpdateRepoSettings(
allow_merge_commit: false,
allow_rebase_merge: rebaseBoolean,
allow_squash_merge: squashBoolean,
delete_branch_on_merge: true,
})
.reply(200);
}
Expand Down

0 comments on commit d2aac97

Please sign in to comment.