Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit 1a64137

Browse files
authored
Use some enum strings directly (#350)
1 parent 251e2ba commit 1a64137

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/pr-info.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { PR_repository_pullRequest as GraphqlPullRequest,
88
PR_repository_pullRequest_timelineItems_nodes_MovedColumnsInProjectEvent,
99
PR_repository_pullRequest_comments_nodes
1010
} from "./queries/schema/PR";
11-
import { PullRequestReviewState, PullRequestState, CommentAuthorAssociation, CheckConclusionState } from "./queries/schema/graphql-global-types";
1211
import { getMonthlyDownloadCount } from "./util/npm";
1312
import { client } from "./graphql-client";
1413
import { fetchFile as defaultFetchFile } from "./util/fetchFile";
@@ -186,13 +185,13 @@ export async function deriveStateForPR(
186185
if (prInfo.author == null) return botError("PR author does not exist");
187186

188187
if (prInfo.isDraft) return botEnsureRemovedFromProject("PR is a draft");
189-
if (prInfo.state !== PullRequestState.OPEN) return botEnsureRemovedFromProject("PR is not active");
188+
if (prInfo.state !== "OPEN") return botEnsureRemovedFromProject("PR is not active");
190189

191190
const headCommit = getHeadCommit(prInfo);
192191
if (headCommit == null) return botError("No head commit found");
193192

194193
const author = prInfo.author.login;
195-
const isFirstContribution = prInfo.authorAssociation === CommentAuthorAssociation.FIRST_TIME_CONTRIBUTOR;
194+
const isFirstContribution = prInfo.authorAssociation === "FIRST_TIME_CONTRIBUTOR";
196195

197196
const createdDate = new Date(prInfo.createdAt);
198197
// apparently `headCommit.pushedDate` can be null in some cases (see #48708), use the PR creation time for that
@@ -460,14 +459,14 @@ function getReviews(prInfo: PR_repository_pullRequest) {
460459
reviews.push({ type: "stale", reviewer, date, abbrOid: abbrOid(r.commit.oid) });
461460
continue;
462461
}
463-
if (r.state === PullRequestReviewState.CHANGES_REQUESTED) {
462+
if (r.state === "CHANGES_REQUESTED") {
464463
reviews.push({ type: "changereq", reviewer, date });
465464
continue;
466465
}
467-
if (r.state !== PullRequestReviewState.APPROVED) continue;
466+
if (r.state !== "APPROVED") continue;
468467
const isMaintainer =
469-
(r.authorAssociation === CommentAuthorAssociation.MEMBER)
470-
|| (r.authorAssociation === CommentAuthorAssociation.OWNER);
468+
(r.authorAssociation === "MEMBER")
469+
|| (r.authorAssociation === "OWNER");
471470
reviews.push({ type: "approved", reviewer, date, isMaintainer });
472471
}
473472
return reviews;
@@ -480,11 +479,11 @@ function getCIResult(checkSuites: PR_repository_pullRequest_commits_nodes_commit
480479
const totalStatusChecks = ghActionsChecks?.find(check => check?.checkRuns?.nodes?.[0]?.title === "test") || ghActionsChecks?.[0];
481480
if (!totalStatusChecks) return { ciResult: "missing", ciUrl: undefined };
482481
switch (totalStatusChecks.conclusion) {
483-
case CheckConclusionState.SUCCESS:
482+
case "SUCCESS":
484483
return { ciResult: "pass" };
485-
case CheckConclusionState.FAILURE:
486-
case CheckConclusionState.SKIPPED:
487-
case CheckConclusionState.TIMED_OUT:
484+
case "FAILURE":
485+
case "SKIPPED":
486+
case "TIMED_OUT":
488487
return { ciResult: "fail", ciUrl: totalStatusChecks.url };
489488
default:
490489
return { ciResult: "unknown" };

0 commit comments

Comments
 (0)