Merge remote-tracking branch 'origin/main' into docs/sync-s3-auto-auth
This commit is contained in:
commit
8abb7393fc
5 changed files with 127 additions and 2 deletions
|
|
@ -82,14 +82,25 @@ function M.parse_buffer(lines)
|
|||
return result
|
||||
end
|
||||
|
||||
---@param a? pending.ForgeRef
|
||||
---@param b? pending.ForgeRef
|
||||
---@return boolean
|
||||
local function refs_equal(a, b)
|
||||
if not a or not b then
|
||||
return false
|
||||
end
|
||||
return a.forge == b.forge and a.owner == b.owner and a.repo == b.repo and a.number == b.number
|
||||
end
|
||||
|
||||
---@param lines string[]
|
||||
---@param s pending.Store
|
||||
---@param hidden_ids? table<integer, true>
|
||||
---@return nil
|
||||
---@return pending.ForgeRef[]
|
||||
function M.apply(lines, s, hidden_ids)
|
||||
local parsed = M.parse_buffer(lines)
|
||||
local now = timestamp()
|
||||
local data = s:data()
|
||||
local new_refs = {} ---@type pending.ForgeRef[]
|
||||
|
||||
local old_by_id = {}
|
||||
for _, task in ipairs(data.tasks) do
|
||||
|
|
@ -120,6 +131,9 @@ function M.apply(lines, s, hidden_ids)
|
|||
order = order_counter,
|
||||
_extra = entry.forge_ref and { _forge_ref = entry.forge_ref } or nil,
|
||||
})
|
||||
if entry.forge_ref then
|
||||
table.insert(new_refs, entry.forge_ref)
|
||||
end
|
||||
else
|
||||
seen_ids[entry.id] = true
|
||||
local task = old_by_id[entry.id]
|
||||
|
|
@ -154,6 +168,10 @@ function M.apply(lines, s, hidden_ids)
|
|||
end
|
||||
end
|
||||
if entry.forge_ref ~= nil then
|
||||
local old_ref = task._extra and task._extra._forge_ref or nil
|
||||
if not refs_equal(old_ref, entry.forge_ref) then
|
||||
table.insert(new_refs, entry.forge_ref)
|
||||
end
|
||||
if not task._extra then
|
||||
task._extra = {}
|
||||
end
|
||||
|
|
@ -188,6 +206,9 @@ function M.apply(lines, s, hidden_ids)
|
|||
order = order_counter,
|
||||
_extra = entry.forge_ref and { _forge_ref = entry.forge_ref } or nil,
|
||||
})
|
||||
if entry.forge_ref then
|
||||
table.insert(new_refs, entry.forge_ref)
|
||||
end
|
||||
end
|
||||
|
||||
::continue::
|
||||
|
|
@ -202,6 +223,7 @@ function M.apply(lines, s, hidden_ids)
|
|||
end
|
||||
|
||||
s:save()
|
||||
return new_refs
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue