feat(updater): include commit timestamps in status response
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d9dc5bf798
commit
e2a86bf30f
1 changed files with 15 additions and 7 deletions
|
|
@ -98,7 +98,9 @@ async function getForgejoCommit(repo) {
|
|||
const res = await fetch(`${FORGEJO_URL}/api/v1/repos/${FORGEJO_ORG}/${repo}/commits?limit=1`, { headers })
|
||||
if (!res.ok) return null
|
||||
const data = await res.json()
|
||||
return data?.[0]?.sha || null
|
||||
const c = data?.[0]
|
||||
if (!c) return null
|
||||
return { sha: c.sha, timestamp: c.created || c.commit?.committer?.date || null }
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
|
|
@ -108,18 +110,24 @@ async function refreshStatus(repo) {
|
|||
const target = getDeployTarget(repo)
|
||||
if (!target) return null
|
||||
|
||||
const [current, latest] = await Promise.all([
|
||||
sshGet(target.host, `git -C ${target.path} rev-parse HEAD 2>/dev/null || echo not-deployed`),
|
||||
const [currentRaw, latest] = await Promise.all([
|
||||
sshGet(target.host, `git -C ${target.path} log -1 --format='%H|%cI' HEAD 2>/dev/null || echo not-deployed`),
|
||||
getForgejoCommit(repo),
|
||||
])
|
||||
|
||||
const deployed = current && current !== 'not-deployed'
|
||||
let currentSha = null, currentTimestamp = null
|
||||
if (currentRaw && currentRaw.includes('|')) {
|
||||
;[currentSha, currentTimestamp] = currentRaw.split('|')
|
||||
}
|
||||
const deployed = !!currentSha
|
||||
const entry = {
|
||||
repo,
|
||||
host: target.host,
|
||||
currentCommit: deployed ? current.slice(0, 12) : (current || 'unreachable'),
|
||||
latestCommit: latest ? latest.slice(0, 12) : 'unknown',
|
||||
updateAvailable: !!(deployed && latest && current && latest !== current),
|
||||
currentCommit: deployed ? currentSha.slice(0, 12) : (currentRaw || 'unreachable'),
|
||||
currentCommitAt: currentTimestamp || null,
|
||||
latestCommit: latest ? latest.sha.slice(0, 12) : 'unknown',
|
||||
latestCommitAt: latest?.timestamp || null,
|
||||
updateAvailable: !!(deployed && latest && currentSha && latest.sha !== currentSha),
|
||||
deployed,
|
||||
checkedAt: new Date().toISOString(),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue