Skip to content

Commit 43aac4c

Browse files
author
meorphis
committed
lint
1 parent 1fc6121 commit 43aac4c

4 files changed

Lines changed: 24 additions & 13 deletions

File tree

src/comment.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ describe("printComment", () => {
1717
});
1818

1919
it("should print no changes comment", () => {
20-
expect(printComment({ noChanges: true, projectName: 'fake project' })).toMatchInlineSnapshot(`
20+
expect(printComment({ noChanges: true, projectName: "fake project" }))
21+
.toMatchInlineSnapshot(`
2122
"<h3>✱ Stainless preview builds for fake project</h3>
2223
2324
No changes were made to the SDKs.

src/comment.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import {
1111
sortDiagnostics,
1212
} from "./outcomes";
1313

14-
const COMMENT_TITLE = (projectName: string | null) => MD.Heading(
15-
`${MD.Symbol.HeavyAsterisk} Stainless preview builds${projectName ? ` for ${projectName}` : ""}`,
16-
);
14+
const COMMENT_TITLE = (projectName: string | null) =>
15+
MD.Heading(
16+
`${MD.Symbol.HeavyAsterisk} Stainless preview builds${projectName ? ` for ${projectName}` : ""}`,
17+
);
1718

1819
const COMMENT_FOOTER_DIVIDER = MD.Comment("stainless-preview-footer");
1920

@@ -42,7 +43,10 @@ export function printComment({
4243
}:
4344
| ({ noChanges?: never } & Omit<PrintCommentOptions, "noChanges">)
4445
| ({ noChanges: true; projectName: string } & {
45-
[K in keyof Omit<Omit<PrintCommentOptions, "noChanges">, "projectName">]?: never;
46+
[K in keyof Omit<
47+
Omit<PrintCommentOptions, "noChanges">,
48+
"projectName"
49+
>]?: never;
4650
})) {
4751
const Blocks = (() => {
4852
if (noChanges) {
@@ -567,12 +571,14 @@ export function parseCommitMessages(body?: string | null): {
567571
export async function retrieveComment(prNumber: number, projectName: string) {
568572
const comments = await api().listComments(prNumber);
569573

570-
const existingComment = comments.find((comment) =>
571-
comment.body?.includes(COMMENT_TITLE(projectName)) || (
572-
// backwards compatibility for comments that don't include the project name
573-
// TODO: remove this fallback eventually
574-
!comment.body?.includes(COMMENT_TITLE(null) + ' for') && comment.body?.includes(COMMENT_TITLE(null))
575-
));
574+
const existingComment = comments.find(
575+
(comment) =>
576+
comment.body?.includes(COMMENT_TITLE(projectName)) ||
577+
// backwards compatibility for comments that don't include the project name
578+
// TODO: remove this fallback eventually
579+
(!comment.body?.includes(COMMENT_TITLE(null) + " for") &&
580+
comment.body?.includes(COMMENT_TITLE(null))),
581+
);
576582

577583
if (!existingComment) {
578584
return null;

src/merge.run.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ export async function runMerge(
117117
}
118118

119119
const comment =
120-
makeComment && prNumber ? await retrieveComment(prNumber, projectName) : null;
120+
makeComment && prNumber
121+
? await retrieveComment(prNumber, projectName)
122+
: null;
121123
const commitMessage =
122124
comment?.commitMessage ??
123125
makeCommitMessageConventional(defaultCommitMessage);

src/preview.run.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ export async function runPreview(
163163

164164
logger.groupEnd();
165165

166-
const initialComment = makeComment ? await retrieveComment(prNumber, projectName) : null;
166+
const initialComment = makeComment
167+
? await retrieveComment(prNumber, projectName)
168+
: null;
167169
let commitMessage =
168170
initialComment?.commitMessage ??
169171
makeCommitMessageConventional(defaultCommitMessage);

0 commit comments

Comments
 (0)