Skip to content

Commit

Permalink
fix: cannot disable automerge and while keeping mergify enabled (#1783)
Browse files Browse the repository at this point in the history
Supersedes #1766
Fixes #1765

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
Chriscbr committed Apr 21, 2022
1 parent 171a0eb commit a64180a
Show file tree
Hide file tree
Showing 6 changed files with 394 additions and 6 deletions.
44 changes: 43 additions & 1 deletion docs/api/API.md

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/github/github-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,16 @@ export interface GitHubProjectOptions extends ProjectOptions {
*/
readonly autoApproveOptions?: AutoApproveOptions;

/**
* Enable automatic merging on GitHub. Has no effect if `github.mergify`
* is set to false.
* @default true
*/
readonly autoMerge?: boolean;

/**
* Configure options for automatic merging on GitHub. Has no effect if
* `github.mergify` is set to false.
* `github.mergify` or `autoMerge` is set to false.
*
* @default - see defaults in `AutoMergeOptions`
*/
Expand Down
8 changes: 6 additions & 2 deletions src/javascript/node-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class NodeProject extends GitHubProject {
}

/**
* Automatic PR merges.
* Component that sets up mergify for merging approved pull requests.
*/
public readonly autoMerge?: AutoMerge;

Expand Down Expand Up @@ -603,7 +603,11 @@ export class NodeProject extends GitHubProject {
}
}

if (this.github?.mergify && this.buildWorkflow?.buildJobIds) {
if (
(options.autoMerge ?? true) &&
this.github?.mergify &&
this.buildWorkflow?.buildJobIds
) {
this.autoMerge = new AutoMerge(this.github, options.autoMergeOptions);
this.autoMerge.addConditionsLater({
render: () =>
Expand Down

0 comments on commit a64180a

Please sign in to comment.