Skip to content

Commit

Permalink
web: use latest git SHA for date picker
Browse files Browse the repository at this point in the history
As it is we are overwriting the mapping with the oldest commit on a
particular date. For dates where there are multiple entries, it usually
means we made some updates for a particular new version or distro. As a
result, it's best to prefer the newest commit on that day, not the
oldest. Let's track this and only use the newest date. We can't use the
set of dates (which you'd expect we could) because the JS "Date" object
is actually date + time, and commits are not likely on the exact same
date and time.

Signed-off-by: Stephen Brennan <[email protected]>
  • Loading branch information
brenns10 committed Jul 15, 2024
1 parent 6ab3a9c commit 702581f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,18 @@ <h5 class="modal-title" id="versionModalLabel">Select Date of Snapshot</h5>
data = JSON.parse(data)
let resp = Array.from(data);
let dates = new Set();
let lastDateStr = undefined;
resp.forEach((res)=>{
const date = new Date(res.commit.committer.date);
const dateStr = dateString(date);

// We encounter commits in reverse chronological order. Use the
// first commit for the date and skip the rest, as we normally
// care about the most recent commit on the date.
if (dateStr === lastDateStr)
return;
lastDateStr = dateStr;

dates.add(date);
versionDateMapping.set(dateStr, res.sha)
// If we started with a SHA, replace it with the date string
Expand Down

0 comments on commit 702581f

Please sign in to comment.