Skip to content

Commit

Permalink
fix: try to enable automerge if disabled on synchronize
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau committed Jan 21, 2023
1 parent 6b989ba commit b9c7729
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions src/events/pr-handlers/synchronize.ts
Expand Up @@ -4,6 +4,8 @@ import { getChecksAndStatusesForPullRequest } from '../../utils/github/pullReque
import { autoMergeIfPossible } from './actions/autoMergeIfPossible';
import { calcAndUpdateLabels } from './actions/calcAndUpdateLabels';
import { editOpenedPR } from './actions/editOpenedPR';
import { enableGithubAutoMerge } from './actions/enableGithubAutoMerge';
import hasLabelInPR from './actions/utils/labels/hasLabelInPR';
import { calcStepsState } from './actions/utils/steps/calcStepsState';
import { createPullRequestHandler } from './utils/createPullRequestHandler';
import { fetchPr } from './utils/fetchPr';
Expand Down Expand Up @@ -70,13 +72,32 @@ export default function synchronize(app: Probot, appContext: AppContext): void {
checksAndStatuses,
});

// call autoMergeIfPossible to re-add to the queue when push is fixed
await autoMergeIfPossible(
updatedPr,
context,
repoContext,
reviewflowPrContext,
);
if (
repoContext.settings.allowAutoMerge &&
repoContext.config.experimentalFeatures?.githubAutoMerge
) {
const autoMergeLabel = repoContext.labels['merge/automerge'];

if (
!pullRequest.auto_merge &&
hasLabelInPR(pullRequest.labels, autoMergeLabel)
) {
await enableGithubAutoMerge(
pullRequest,
context,
repoContext,
reviewflowPrContext,
);
}
} else {
// call autoMergeIfPossible to re-add to the queue when push is fixed
await autoMergeIfPossible(
updatedPr,
context,
repoContext,
reviewflowPrContext,
);
}
},
);
}

0 comments on commit b9c7729

Please sign in to comment.