From 616dbac916275fa0051306a384eb64cf983287be Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 1 Sep 2022 13:20:31 -0700 Subject: [PATCH] zigmod.lock: alphabetize the list of dependencies to be order independent --- src/cmd/fetch.zig | 2 ++ src/util/module.zig | 9 +++++++++ zigmod.lock | 28 ++++++++++++++-------------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/cmd/fetch.zig b/src/cmd/fetch.zig index 855e029189d236de83aca64010670247c206c21f..18ed59f7b8eec7a1fb2481408449762da22555c7 100644 --- a/src/cmd/fetch.zig +++ b/src/cmd/fetch.zig @@ -141,6 +141,8 @@ fn create_lockfile(alloc: std.mem.Allocator, list: *std.ArrayList(zigmod.Module) const fl = try dir.createFile("zigmod.lock", .{}); defer fl.close(); + std.sort.sort(zigmod.Module, list.items, {}, zigmod.Module.lessThan); + const wl = fl.writer(); try wl.writeAll("2\n"); for (list.items) |m| { diff --git a/src/util/module.zig b/src/util/module.zig index 5bb7d13304467044ffadce0dc27af79ed39f6309..e8a131af1e4fe9cb78ecf8fb0a7c0687f8f6b68e 100644 --- a/src/util/module.zig +++ b/src/util/module.zig @@ -150,4 +150,13 @@ pub const Module = struct { } return res; } + + pub fn lessThan(_: void, lhs: Module, rhs: Module) bool { + for (lhs.clean_path) |_, i| { + if (i == rhs.clean_path.len) return false; + if (lhs.clean_path[i] < rhs.clean_path[i]) return true; + if (lhs.clean_path[i] > rhs.clean_path[i]) return false; + } + return false; + } }; diff --git a/zigmod.lock b/zigmod.lock index d775acbde4bf2fbe4f393079cf601dff79393b02..fbdb7c856f507e9ad32b8c0779ef5b05f869fe96 100644 --- a/zigmod.lock +++ b/zigmod.lock @@ -1,19 +1,19 @@ 2 -git https://github.com/yaml/libyaml tag-0.2.5 -git https://github.com/nektro/zig-ansi commit-d4a53bcac5b87abecc65491109ec22aaf5f3dc2f -git https://github.com/ziglibs/known-folders commit-24845b0103e611c108d6bc334231c464e699742c -git https://github.com/nektro/zig-licenses commit-c9b8cbf3565675a056ad4e9b57cb4f84020e7680 -git https://github.com/truemedian/zfetch commit-12b1374aae32e8ebf719a096a22cdf4c49433458 -git https://github.com/truemedian/hzzp commit-d4fbade2d806fc93bc5f79ec8efdcc25ea625fa3 -git https://github.com/nektro/iguanaTLS commit-09d9fe92f329484536dfb2b07cfa8b406151cde4 git https://github.com/MasterQ32/zig-uri commit-e879df3a236869f92298fbe2db3c25e6e84cfd4c -git https://github.com/nektro/zig-json commit-a091eaa9f9ae91c3875630ba1983b33ea04971a3 -git https://github.com/nektro/zig-extras commit-01fae956e2f17aa992e717e041a3dd457d440b31 -git https://github.com/nektro/zig-range commit-4b2f12808aa09be4b27a163efc424dd4e0415992 +git https://github.com/marlersoft/zigwin32 commit-2b40704fbc2c9fbdb6f31acbc48684b6b98c15e3 +git https://github.com/nektro/arqv-ini commit-1a9b2e90379895e197893b6e19c93bd213ad36e6 +git https://github.com/nektro/iguanaTLS commit-09d9fe92f329484536dfb2b07cfa8b406151cde4 +git https://github.com/nektro/zig-ansi commit-d4a53bcac5b87abecc65491109ec22aaf5f3dc2f git https://github.com/nektro/zig-detect-license commit-de5c285d999eea68b9189b48bb000243fef0a689 -git https://github.com/nektro/zig-licenses-text commit-3c07c6e4eb0965dafd0b029c632f823631b3169c -git https://github.com/nektro/zig-leven commit-ab852cf74fa0b4edc530d925f0654b62c60365bf +git https://github.com/nektro/zig-extras commit-01fae956e2f17aa992e717e041a3dd457d440b31 git https://github.com/nektro/zig-inquirer commit-14c3492c46f9765c3e77436741794d1a3118cbee -git https://github.com/nektro/arqv-ini commit-1a9b2e90379895e197893b6e19c93bd213ad36e6 +git https://github.com/nektro/zig-json commit-a091eaa9f9ae91c3875630ba1983b33ea04971a3 +git https://github.com/nektro/zig-leven commit-ab852cf74fa0b4edc530d925f0654b62c60365bf +git https://github.com/nektro/zig-licenses commit-c9b8cbf3565675a056ad4e9b57cb4f84020e7680 +git https://github.com/nektro/zig-licenses-text commit-3c07c6e4eb0965dafd0b029c632f823631b3169c +git https://github.com/nektro/zig-range commit-4b2f12808aa09be4b27a163efc424dd4e0415992 git https://github.com/nektro/zig-time commit-a22054de725ef19b3f91b9ad960d4093f852b7e0 -git https://github.com/marlersoft/zigwin32 commit-2b40704fbc2c9fbdb6f31acbc48684b6b98c15e3 +git https://github.com/truemedian/hzzp commit-d4fbade2d806fc93bc5f79ec8efdcc25ea625fa3 +git https://github.com/truemedian/zfetch commit-12b1374aae32e8ebf719a096a22cdf4c49433458 +git https://github.com/ziglibs/known-folders commit-24845b0103e611c108d6bc334231c464e699742c +git https://github.com/yaml/libyaml tag-0.2.5 -- 2.54.0