Open squeek502 opened 5 years ago
Btw, here's a small little command I was using for testing the existence of a snapshot hash. Name it snapshot.lua
and put it in lit/commands
:
return function()
local config = require('autoconfig')()
local makeDb = require('db')
local pkg = require('pkg')
local log = require("log").log
local db = makeDb(config.database)
local author_arg = assert(args[2], "missing author argument")
local name_arg = assert(args[3], "missing name argument")
local version_arg = assert(args[4], "missing version argument")
print("")
if version_arg then
local author = author_arg
local name = name_arg
local version = version_arg
local package = db.read(author, name, version)
assert(package, author .. "/" .. name .. "@" .. version .. " not found")
local meta = pkg.queryDb(db, package)
local snapshotHash = meta.snapshot
log("snapshot hash", snapshotHash)
assert(pkg.queryDb(db, snapshotHash))
end
print("")
end
Use it via luvi . -- snapshot <author> <name> <version>
.
Creates a new tag for each snapshot hash at
refs/snapshots/<author>/<name>/v<version>
with the tag namesnapshots/<author>/<name>/v<version>
. The tag ref is created outside ofrefs/tags
so that other methods that iterate the refs don't include snapshots in their iterations (i.e.db.authors()
simply returns all nodes inrefs/tags
). It's confirmed that the tag being inrefs/snapshots
still makes it exempt fromgit gc
: without the tag,git gc --prune=all
prunes the snapshot hash, but with the tag it remains aftergit gc --prune=all
.Note: This is an incomplete implementation; it only creates the snapshot tag in
lit add
, not on the server duringlit publish
(or any other places where it might also need to be created)This is the other half of #247
I feel like I'm getting a bit in over my head with this, since I'm not super familiar with the db structure/lit internals/git internals/etc, so I thought I'd push the bit that I've got so far for feedback. As far as I can tell, what needs to be done to finish this up is evaluate/update the other instances of
db.write
throughout the code (rdb.lua, handlers.lua) to also create the snapshot tag.