You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we normalize sources by deduplicating on `sourceId`, we end up losing a little bit of data that's important for being able to reconnect `source` objects with their lines in `library/foo`.
This resolves that by adjusting our `entry` object to be a vector of `entries` instead, but sorted using the same `SOURCE_DATE_EPOCH` tiebreaker we used previously so that `.entries[0]` is the same as our old `.entry`, but we keep the full list of values for later use/lookup/cross-referencing.
I have additionally verified that `meta.jq` here was the only place we are actively consuming from the `.entry` object (currently), so this should be fully sufficient (no changes necessary elsewhere).
# "bashbrew fetch" but in Bash (because we have bashbrew, but not the library file -- we could synthesize a library file instead, but six of one half a dozen of another)
| if .entry.SOURCE_DATE_EPOCH > $in.entry.SOURCE_DATE_EPOCH then
115
-
# smallest SOURCE_DATE_EPOCH wins in the face of duplicates for a given sourceId
116
-
.entry = $in.entry
117
-
else . end
114
+
| .entries = (
115
+
reduce $in.entries[] as $inE (.entries;
116
+
# "unique" but without losing ordering (ie, only add entries we do not already have)
117
+
if index($inE) then . else
118
+
. + [ $inE ]
119
+
end
120
+
)
121
+
# then prefer lower SOURCE_DATE_EPOCH earlier, so .entries[0] is the "preferred" (oldest) commit/entry
122
+
| sort_by(.SOURCE_DATE_EPOCH)
123
+
# (this does not lose *significant* ordering because it is a "stable sort", so same SOURCE_DATE_EPOCH gets the same position, unlike "unique_by" which would be destructive, even though it is ultimately what we are emulating with this two-part construction of a new .entries value)
124
+
)
118
125
end
119
126
)
120
127
# TODO a lot of this could be removed/parsed during the above reduce, since it has to parse things in build order anyhow
0 commit comments