Skip to content

Commit

Permalink
Handle PRs with all commits filtered (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Sep 22, 2022
1 parent a6bb619 commit c05ba5e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions services/bots/src/github-webhook/handlers/validate-cla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export class ValidateCla extends BaseWebhookHandler {
}

const commits = await context.github.pulls.listCommits(context.pullRequest({ per_page: 100 }));
const allCommitsIgnored = commits.data.every(
(commit) => commit.author?.type === 'Bot' || ignoredAuthors.has(commit.commit?.author?.email),
);

for await (const commit of commits.data) {
if (commit.author?.type === 'Bot' || ignoredAuthors.has(commit.commit?.author?.email)) {
Expand Down Expand Up @@ -196,7 +199,9 @@ export class ValidateCla extends BaseWebhookHandler {
}

// If we get here, all is good :+1:
context.scheduleIssueLabel(ClaIssueLabel.CLA_SIGNED);
if (!allCommitsIgnored) {
context.scheduleIssueLabel(ClaIssueLabel.CLA_SIGNED);
}
try {
await context.github.issues.removeLabel(
context.issue({
Expand All @@ -212,7 +217,9 @@ export class ValidateCla extends BaseWebhookHandler {
context.repo({
sha: commit.sha,
state: 'success',
description: 'Everyone involved has signed the CLA',
description: `Everyone involved ${
allCommitsIgnored ? 'are ignored' : 'has signed the CLA'
}`,
context: botContextName,
}),
);
Expand Down

0 comments on commit c05ba5e

Please sign in to comment.