sorted toml for better git merge

This commit is contained in:
schreifuchs 2024-11-06 11:36:46 +01:00
parent ad454d9cf8
commit 0dbfa8f422
3 changed files with 27 additions and 4 deletions

View File

@ -1,9 +1,11 @@
## dates and their corresponding seconds been here :) ## dates and their corresponding seconds been here :)
[24-10-08]
u80864958_at_u80864958 = 425
[24-10-07] [24-10-07]
u80864958_at_u80864958 = 432 u80864958_at_u80864958 = 432
[24-10-08]
u80864958_at_u80864958 = 425
[24-10-11] [24-10-11]
u80864958_at_u80864958 = 6021 u80864958_at_u80864958 = 6021
[24-10-15] [24-10-15]
schreifuchs_at_archlinux = 128 schreifuchs_at_archlinux = 128
[24-11-06]
schreifuchs_at_archibald = 301

11
.timer.toml.b Normal file
View File

@ -0,0 +1,11 @@
## dates and their corresponding seconds been here :)
[24-10-07]
u80864958_at_u80864958 = 432
[24-10-08]
u80864958_at_u80864958 = 425
[24-10-11]
u80864958_at_u80864958 = 6021
[24-10-15]
schreifuchs_at_archlinux = 128
[24-11-06]
schreifuchs_at_archibald = 18

View File

@ -564,7 +564,17 @@ TOML.encode = function(tbl)
local cache = {} local cache = {}
local function parse(tbl) local function parse(tbl)
for k, v in pairs(tbl) do local tbl_keys = {}
for k in pairs(tbl) do
table.insert(tbl_keys, k)
end
table.sort(tbl_keys)
for _, k in pairs(tbl_keys) do
local v = tbl[k]
print(k)
print(v)
if type(v) == "boolean" then if type(v) == "boolean" then
toml = toml .. k .. " = " .. tostring(v) .. "\n" toml = toml .. k .. " = " .. tostring(v) .. "\n"
elseif type(v) == "number" then elseif type(v) == "number" then
@ -572,7 +582,7 @@ TOML.encode = function(tbl)
elseif type(v) == "string" then elseif type(v) == "string" then
local quote = '"' local quote = '"'
v = v:gsub("\\", "\\\\") v = v:gsub("\\", "\\\\")
--
-- if the string has any line breaks, make it multiline -- if the string has any line breaks, make it multiline
if v:match("^\n(.*)$") then if v:match("^\n(.*)$") then
quote = quote:rep(3) quote = quote:rep(3)