Skip to content

Commit cabface

Browse files
committed
fix: sort conflict comments by date to correctly identify and compare the latest entry
1 parent 823d06e commit cabface

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

.github/workflows/conflict-notifier.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ jobs:
8787
repo: context.repo.repo,
8888
issue_number: pr.number,
8989
per_page: 100,
90+
sort: 'created',
91+
direction: 'desc',
9092
});
9193
9294
const conflictComments = comments.filter(c =>
@@ -98,11 +100,11 @@ jobs:
98100
if (conflictComments.length === 0) {
99101
shouldComment = true;
100102
} else {
101-
const lastComment = conflictComments[conflictComments.length - 1];
102-
const lastCommentTime = new Date(lastComment.created_at).getTime();
103+
const latestComment = conflictComments[0];
104+
const latestCommentTime = new Date(latestComment.created_at).getTime();
103105
const nowTime = new Date().getTime();
104106
const TWENTY_FOUR_HOURS_MS = 24 * 60 * 60 * 1000;
105-
if (nowTime - lastCommentTime >= TWENTY_FOUR_HOURS_MS) {
107+
if (nowTime - latestCommentTime >= TWENTY_FOUR_HOURS_MS) {
106108
shouldComment = true;
107109
}
108110
}

0 commit comments

Comments
 (0)