Save snapshots as tags so they don't get deleted by git gc#251
Draft
squeek502 wants to merge 1 commit intoluvit:masterfrom
Draft
Save snapshots as tags so they don't get deleted by git gc#251squeek502 wants to merge 1 commit intoluvit:masterfrom
squeek502 wants to merge 1 commit intoluvit:masterfrom
Conversation
Creates a new tag for each snapshot hash at `refs/snapshots/<author>/<name>/v<version>` with the tag name `snapshots/<author>/<name>/v<version>`. The tag ref is created outside of `refs/tags` so that other methods that iterate the refs don't include snapshots in their iterations (i.e. db.authors() simply returns all nodes in `refs/tags`). It's confirmed that the tag being in `refs/snapshots` still makes it exempt from `git gc`: without the tag, `git gc --prune=all` prunes the snapshot hash, but with the tag it remains after `git gc --prune=all`. Note: This is an incomplete implementation; it only creates the snapshot tag in `lit add`, not on the server during `lit publish` (or any other places where it might also need to be created)
Member
Author
|
Btw, here's a small little command I was using for testing the existence of a snapshot hash. Name it 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("")
endUse it via |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/tagsso 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/snapshotsstill makes it exempt fromgit gc: without the tag,git gc --prune=allprunes 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.writethroughout the code (rdb.lua, handlers.lua) to also create the snapshot tag.