Skip to content

Commit 5bc8e9e

Browse files
fix(shared): composer # suggestions sort by update instant, not timestamp text
Self-hosted GitLab can report updated_at with different UTC offsets, so comparing the strings misordered matches and the 12-row limit could drop a newer merge request. Compare parsed instants instead. AI-assisted; verified with the tests and tools listed above.
1 parent e3223f9 commit 5bc8e9e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎packages/shared/src/composerPullRequestMatches.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ export function filterComposerPullRequestMatches<
6363
}
6464
const isExactMatch = (entry: ComposerPullRequestMatch) => String(entry.number) === input.query;
6565
const isLinked = (entry: ComposerPullRequestMatch) => linkedKeys.has(keyOf(entry));
66+
const updatedAtMs = (entry: ComposerPullRequestMatch) => Date.parse(entry.updatedAt) || 0;
6667
// Hermes has no ES2023 array methods, so sort a fresh array.
6768
return [...uniqueEntries.values()]
6869
.sort(
6970
(left, right) =>
7071
Number(isExactMatch(right)) - Number(isExactMatch(left)) ||
7172
Number(isLinked(right)) - Number(isLinked(left)) ||
72-
right.updatedAt.localeCompare(left.updatedAt),
73+
updatedAtMs(right) - updatedAtMs(left),
7374
)
7475
.slice(0, input.limit);
7576
}

0 commit comments

Comments
 (0)