@@ -512,22 +512,19 @@ View the [build log](https://storage.cloud.google.com/ci-vcr-logs/beta/refs/head
512512 return false , nil
513513}
514514
515+ // appendVCRResultToDiffComment appends content to the existing diff report comment
516+ // identified by the ID in /workspace/diff_comment_id.txt.
517+ // If the file is missing or the comment cannot be fetched, it falls back to posting a new comment.
515518func appendVCRResultToDiffComment (prNumber string , content string , gh GithubClient , rnr ExecRunner ) error {
516- comments , err := gh .GetPullRequestComments (prNumber )
517- if err != nil {
518- return fmt .Errorf ("error getting PR comments: %w" , err )
519- }
520-
521519 var diffComment * github.PullRequestComment
522520
523521 // Try to find by ID from file
524522 if idStr , err := rnr .ReadFile ("/workspace/diff_comment_id.txt" ); err == nil {
525523 if id , err := strconv .Atoi (strings .TrimSpace (idStr )); err == nil {
526- for _ , c := range comments {
527- if c .ID == id {
528- diffComment = & c
529- break
530- }
524+ if comment , err := gh .GetPullRequestComment (id ); err == nil {
525+ diffComment = & comment
526+ } else {
527+ fmt .Printf ("Warning: failed to fetch comment %d by ID: %v\n " , id , err )
531528 }
532529 }
533530 }
@@ -538,7 +535,7 @@ func appendVCRResultToDiffComment(prNumber string, content string, gh GithubClie
538535 }
539536
540537 // Fallback to posting a new comment if diff report not found
541- _ , err = gh .PostComment (prNumber , content )
538+ _ , err : = gh .PostComment (prNumber , content )
542539 return err
543540}
544541
0 commit comments