Skip to content

Commit

Permalink
sort modules.json for stable order (#32618)
Browse files Browse the repository at this point in the history
  • Loading branch information
yokomotod authored Feb 13, 2023
1 parent b7042e8 commit a62f4f0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/modsdir/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"os"
"path/filepath"
"sort"
"strings"

version "github.com/hashicorp/go-version"
Expand Down Expand Up @@ -136,7 +137,14 @@ func ReadManifestSnapshotForDir(dir string) (Manifest, error) {
func (m Manifest) WriteSnapshot(w io.Writer) error {
var write manifestSnapshotFile

for _, record := range m {
var keys []string
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
record := m[k]

// Make sure VersionStr is in sync with Version, since we encourage
// callers to manipulate Version and ignore VersionStr.
if record.Version != nil {
Expand Down

0 comments on commit a62f4f0

Please sign in to comment.