Skip to content

Commit c87d196

Browse files
committed
Sort entries in lockJSON
- Closes #255
1 parent 14d577a commit c87d196

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

subcmd/get.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ func (*getCmd) updateReposVersion(lockJSON *lockjson.LockJSON, reposPath pathuti
583583
}
584584
// Add repos to 'repos'
585585
lockJSON.Repos = append(lockJSON.Repos, *repos)
586+
sort.SliceStable(lockJSON.Repos, func(i, j int) bool {
587+
return strings.ToLower(lockJSON.Repos[i].Path.FullPath()) < strings.ToLower(lockJSON.Repos[j].Path.FullPath())
588+
})
586589
added = true
587590
} else {
588591
// repos is found in lock.json
@@ -593,8 +596,12 @@ func (*getCmd) updateReposVersion(lockJSON *lockjson.LockJSON, reposPath pathuti
593596
if !profile.ReposPath.Contains(reposPath) {
594597
// Add repos to 'profiles[]/repos_path'
595598
profile.ReposPath = append(profile.ReposPath, reposPath)
599+
sort.SliceStable(profile.ReposPath, func(i, j int) bool {
600+
return strings.ToLower(profile.ReposPath[i].FullPath()) < strings.ToLower(profile.ReposPath[j].FullPath())
601+
})
596602
added = true
597603
}
604+
598605
return added
599606
}
600607

0 commit comments

Comments
 (0)