Skip to content

Commit

Permalink
Add an explicit sort to squash diffs.
Browse files Browse the repository at this point in the history
This eliminates a subtle source of locked config diffs depending on whether we sort with or without the version string present.

Signed-off-by: Matt Moore <[email protected]>
  • Loading branch information
mattmoor committed Dec 17, 2024
1 parent 559534f commit cf5dddd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/build/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ func unify(originals []string, inputs []resolved) (map[string][]string, map[stri
for _, pkg := range sets.List(acc.packages) {
pl = append(pl, fmt.Sprintf("%s=%s", pkg, acc.versions[pkg]))
}
// Sort the package list explicitly with the `=` included.
// This is because (foo, foo-bar) sorts differently than (foo=1, foo-bar=1)
// due to the presence or absence of the `=` character.
sort.Strings(pl)

// "index" is a sentinel value for the intersectino of all architectures.
// This is a reference to the OCI image index we'll be producing with it.
Expand All @@ -247,6 +251,10 @@ func unify(originals []string, inputs []resolved) (map[string][]string, map[stri
for _, pkg := range sets.List(input.packages) {
pl = append(pl, fmt.Sprintf("%s=%s", pkg, input.versions[pkg]))
}
// Sort the package list explicitly with the `=` included.
// This is because (foo, foo-bar) sorts differently than (foo=1, foo-bar=1)
// due to the presence or absence of the `=` character.
sort.Strings(pl)
byArch[input.arch] = pl
}

Expand Down

0 comments on commit cf5dddd

Please sign in to comment.