@@ -149,7 +149,7 @@ export async function createIssue(postResult: boolean, title: string, bodyChunks
149
149
}
150
150
}
151
151
152
- export async function createComment ( prNumber : number , statusComment : number , postResult : boolean , bodyChunks : readonly string [ ] ) : Promise < void > {
152
+ export async function createComment ( prNumber : number , statusComment : number , distinctId : string , postResult : boolean , bodyChunks : readonly string [ ] , somethingChanged : boolean ) : Promise < void > {
153
153
const newComments = bodyChunks . map ( body => ( {
154
154
...repoProperties ,
155
155
issue_number : prNumber ,
@@ -181,26 +181,41 @@ export async function createComment(prNumber: number, statusComment: number, pos
181
181
newCommentUrls . push ( newCommentUrl ) ;
182
182
}
183
183
184
- // Update typescript-bot comment
185
- const comment = await kit . issues . getComment ( {
186
- ...repoProperties ,
187
- comment_id : statusComment
188
- } ) ;
189
184
190
- let newBody = `${ comment . data . body } \n\n` ;
191
- if ( newCommentUrls . length === 1 ) {
192
- newBody += `Update: [The results are in!](${ newCommentUrls [ 0 ] } )` ;
193
- }
194
- else {
195
- newBody += `Update: The results are in! ` ;
196
- newBody += newCommentUrls . map ( ( url , i ) => `[Part ${ i + 1 } ](${ url } )` ) . join ( ", " ) ;
197
- }
185
+ const emoji = ! somethingChanged ? "✅" : "👀" ;
198
186
199
- await kit . issues . updateComment ( {
200
- ...repoProperties ,
201
- comment_id : statusComment ,
202
- body : newBody
203
- } ) ;
187
+ const toReplace = `<!--result-${ distinctId } -->` ;
188
+ let posted = false ;
189
+ for ( let i = 0 ; i < 5 ; i ++ ) {
190
+ // Get status comment contents
191
+ const statusCommentResp = await kit . issues . getComment ( {
192
+ comment_id : statusComment ,
193
+ owner : "Microsoft" ,
194
+ repo : "TypeScript" ,
195
+ } ) ;
196
+
197
+ const oldComment = statusCommentResp . data . body ;
198
+ if ( ! oldComment ?. includes ( toReplace ) ) {
199
+ posted = true ;
200
+ break ;
201
+ }
202
+
203
+ const newComment = oldComment . replace (
204
+ toReplace ,
205
+ `[${ emoji } Results](${ newCommentUrls [ 0 ] } )` ,
206
+ ) ;
207
+
208
+ // Update status comment
209
+ await kit . issues . updateComment ( {
210
+ comment_id : statusComment ,
211
+ owner : "Microsoft" ,
212
+ repo : "TypeScript" ,
213
+ body : newComment ,
214
+ } ) ;
215
+
216
+ // Repeat; someone may have edited the comment at the same time.
217
+ await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
218
+ }
204
219
}
205
220
206
221
export async function checkout ( cwd : string , branch : string ) {
0 commit comments