@@ -11,9 +11,10 @@ import {
1111 sortDiagnostics ,
1212} from "./outcomes" ;
1313
14- const COMMENT_TITLE = MD . Heading (
15- `${ MD . Symbol . HeavyAsterisk } Stainless preview builds` ,
16- ) ;
14+ const COMMENT_TITLE = ( projectName : string | null ) =>
15+ MD . Heading (
16+ `${ MD . Symbol . HeavyAsterisk } Stainless preview builds${ projectName ? ` for ${ projectName } ` : "" } ` ,
17+ ) ;
1718
1819const COMMENT_FOOTER_DIVIDER = MD . Comment ( "stainless-preview-footer" ) ;
1920
@@ -41,8 +42,11 @@ export function printComment({
4142 outcomes,
4243} :
4344 | ( { noChanges ?: never } & Omit < PrintCommentOptions , "noChanges" > )
44- | ( { noChanges : true } & {
45- [ K in keyof Omit < PrintCommentOptions , "noChanges" > ] ?: never ;
45+ | ( { noChanges : true ; projectName : string } & {
46+ [ K in keyof Omit <
47+ Omit < PrintCommentOptions , "noChanges" > ,
48+ "projectName"
49+ > ] ?: never ;
4650 } ) ) {
4751 const Blocks = ( ( ) => {
4852 if ( noChanges ) {
@@ -84,7 +88,7 @@ export function printComment({
8488 . replace ( / \. \d + Z $ / , " UTC" ) ;
8589
8690 const fullComment = MD . Dedent `
87- ${ COMMENT_TITLE }
91+ ${ COMMENT_TITLE ( projectName ) }
8892
8993 ${ Blocks }
9094
@@ -564,11 +568,16 @@ export function parseCommitMessages(body?: string | null): {
564568 : { } ;
565569}
566570
567- export async function retrieveComment ( prNumber : number ) {
571+ 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 ) ,
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 ) ) ) ,
572581 ) ;
573582
574583 if ( ! existingComment ) {
0 commit comments