Skip to content

Commit

Permalink
handle converting pr to/from draft
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Jul 7, 2024
1 parent 56e0a28 commit 7b41e96
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/handlers/checkSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default (app: Probot) => {

const pr = await PullRequest.getFromNumber(context, prNum);

if (pr.wip) return;
if (pr.wip || pr.data.draft) return;

const suites = (
await context.octokit.checks.listSuitesForRef({
Expand Down
26 changes: 25 additions & 1 deletion src/handlers/pullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default (app: Probot) => {

let title = pr.data.title;

if (!pr.wip) {
if (!pr.wip && !pr.data.draft) {
title = `[WIP] ${title}`;
await pr.setTitle(title);
}
Expand Down Expand Up @@ -36,4 +36,28 @@ export default (app: Probot) => {
await pr.clearLabels();
}
});

app.on(['pull_request.converted_to_draft'], async context => {
const pr = new PullRequest(context);

let title = pr.data.title;
if (pr.wip) {
title = title.substring(6);
await pr.setTitle(title);
}

await pr.addLabel('wip');
});

app.on(['pull_request.ready_for_review'], async context => {
const pr = new PullRequest(context);

let title = pr.data.title;
if (pr.wip) {
title = title.substring(6);
await pr.setTitle(title);
}

await pr.addLabel('readyForReview');
});
};

0 comments on commit 7b41e96

Please sign in to comment.