File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name = " ITensorFormatter"
22uuid = " b6bf39f1-c9d3-4bad-aad8-593d802f65fd"
3- version = " 0.2.22 "
3+ version = " 0.2.23 "
44authors = [" ITensor developers <support@itensor.org> and contributors" ]
55
66[workspace ]
Original file line number Diff line number Diff line change 2222function format_project_toml! (path:: AbstractString )
2323 @assert isfile (path) " Expected a file path, got: $path "
2424 isprojecttoml (path) || return nothing
25- # This calls `strip_compat_trailing_zeros!(path)` internally.
2625 strip_compat_trailing_zeros! (path)
26+ # Always canonicalize ordering/formatting, even if compat did not change.
27+ sort_project_toml! (path)
2728 return nothing
2829end
2930
@@ -64,8 +65,10 @@ function sort_project_toml!(path::AbstractString)
6465 for k in sort (collect (keys (data)))
6566 is_table (data[k]) && ! (k in seen) && push! (table_keys, k)
6667 end
67- for k in table_keys
68- println (io)
68+ for (i, k) in pairs (table_keys)
69+ if i > 1 || ! isempty (scalar_keys)
70+ println (io)
71+ end
6972 TOML. print (io, Dict (k => data[k]); sorted = true )
7073 end
7174 out = String (take! (io))
@@ -103,6 +106,5 @@ function strip_compat_trailing_zeros!(path::AbstractString)
103106 open (path, " w" ) do io
104107 return TOML. print (io, data)
105108 end
106- sort_project_toml! (path)
107109 return true
108110end
Original file line number Diff line number Diff line change 3333 @test occursin (" Julia = \" 1.10\" " , result)
3434 @test occursin (" Foo = \" 1.2, 2\" " , result)
3535 end
36+
37+ mktempdir () do dir
38+ path = joinpath (dir, " Project.toml" )
39+ write (
40+ path,
41+ """
42+ [deps]
43+ Zebra = "00000000-0000-0000-0000-000000000001"
44+ Alpha = "00000000-0000-0000-0000-000000000002"
45+ """
46+ )
47+ format_project_tomls! (path)
48+ result = read (path, String)
49+ @test ! startswith (result, " \n " )
50+ @test findfirst (" Alpha" , result) < findfirst (" Zebra" , result)
51+ end
3652end
You can’t perform that action at this time.
0 commit comments