Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions libs/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ local function makeCore(config)
local encoded = encoders.tag({
object = hash,
type = kind,
tag = author .. '/' .. name .. "/v" .. version,
tag = fullTag,
tagger = {
name = config.name,
email = config.email,
Expand All @@ -170,6 +170,27 @@ local function makeCore(config)
local tagHash = db.saveAs("tag", encoded)
db.write(author, name, version, tagHash)
log("new tag", fullTag, "success")

if meta.snapshot then
local snapshotEncoded = encoders.tag({
object = meta.snapshot,
type = kind,
tag = "snapshots/" .. fullTag,
tagger = {
name = config.name,
email = config.email,
date = getdate()
},
message = ""
})
if key then
snapshotEncoded = sshRsa.sign(snapshotEncoded, key)
end
local snapshotTagHash = db.saveAs("tag", snapshotEncoded)
db.write(author, name, version, snapshotTagHash, true)
log("new snapshot", 'snapshots/' .. fullTag, "success")
end

return author, name, version, tagHash
end

Expand Down Expand Up @@ -330,7 +351,7 @@ local function makeCore(config)
if fingerprints[fingerprint] then
fingerprints[fingerprint]= nil
else
log("revoking key", username .. ' ' .. fingerprint, "error")
log("revoking key", username .. ' ' .. fingerprint, "failure")
db.revokeKey(username, fingerprint)
end
end
Expand Down
14 changes: 9 additions & 5 deletions libs/db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,20 @@ return function (rootPath)
return match, assert(db.read(author, name, match))
end

function db.read(author, name, version)
function db.tagRef(author, name, version, isSnapshot)
version = normalize(version)
local ref = string.format("refs/tags/%s/%s/v%s", author, name, version)
local refDir = isSnapshot and "snapshots" or "tags"
return string.format("refs/%s/%s/%s/v%s", refDir, author, name, version)
end

function db.read(author, name, version, isSnapshot)
local ref = db.tagRef(author, name, version, isSnapshot)
return db.getRef(ref)
end

function db.write(author, name, version, hash)
version = normalize(version)
function db.write(author, name, version, hash, isSnapshot)
assertHash(hash)
local ref = string.format("refs/tags/%s/%s/v%s", author, name, version)
local ref = db.tagRef(author, name, version, isSnapshot)
storage.write(ref, hash .. "\n")
end

Expand Down