vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Neutralize host LFS filters when archiving
73f6a9f92b7474e9a62821656cb1baf8a3bac24f · Keenan Nemetz · 13d ago · parent 7b812b6f
Neutralize host LFS filters when archiving git archive runs smudge filters. A host with git lfs install in its global configuration made the server invoke git-lfs while building a release tarball, which tried to fetch from no remote and failed; CI found it because its image installs git-lfs globally. Archive output must be the committed bytes whatever the host has. Pass -c filter.lfs.process= and smudge=cat for both archive paths. The existing LFS rewrite then replaces pointers with stored objects; the plain path keeps pointers, deterministically.
core/git/archive.go +21−10
| @@ -26,6 +26,25 @@ import ( | |||
| 26 | 26 | "rodent.software/vole/core/lfs" | |
| 27 | 27 | ) | |
| 28 | 28 | ||
| 29 | // archiveArgs builds the git invocation. The filter.lfs overrides make the | ||
| 30 | // output the committed bytes no matter what the host has installed: git archive | ||
| 31 | // runs smudge filters, and a machine with `git lfs install` in a global config | ||
| 32 | // would make the server fetch from itself (or fail) while building an archive. | ||
| 33 | // Vole owns LFS, so the driver is neutralized and pointers are handled here. | ||
| 34 | func archiveArgs(format, rev, prefix string) []string { | ||
| 35 | args := []string{ | ||
| 36 | "-c", "filter.lfs.process=", | ||
| 37 | "-c", "filter.lfs.smudge=cat", | ||
| 38 | "-c", "filter.lfs.clean=cat", | ||
| 39 | "-c", "filter.lfs.required=false", | ||
| 40 | "archive", "--format=" + format, | ||
| 41 | } | ||
| 42 | if prefix != "" { | ||
| 43 | args = append(args, "--prefix="+prefix) | ||
| 44 | } | ||
| 45 | return append(args, rev) | ||
| 46 | } | ||
| 47 | |||
| 29 | 48 | // LFSResolver returns the stored bytes for the pointer's object. The caller | |
| 30 | 49 | // closes the reader. Returning an error aborts the archive: a tarball that | |
| 31 | 50 | // silently kept a pointer would be the surprise this exists to remove. | |
| @@ -38,11 +57,7 @@ type LFSResolver func(oid string, size int64) (io.ReadCloser, error) | |||
| 38 | 57 | // The caller owns the response: bytes are written as git produces them, so a | |
| 39 | 58 | // failure part-way is a truncated download, not an error this can report. | |
| 40 | 59 | func (r *Repo) Archive(w io.Writer, rev, format, prefix string) error { | |
| 41 | args := []string{"archive", "--format=" + format} | ||
| 42 | if prefix != "" { | ||
| 43 | args = append(args, "--prefix="+prefix) | ||
| 44 | } | ||
| 45 | args = append(args, rev) | ||
| 60 | args := archiveArgs(format, rev, prefix) | ||
| 46 | 61 | cmd := r.command(args...) | |
| 47 | 62 | var errb bytes.Buffer | |
| 48 | 63 | cmd.Stderr = &errb | |
| @@ -72,11 +87,7 @@ func (r *Repo) ArchiveResolvingLFS(w io.Writer, rev, format, prefix string, reso | |||
| 72 | 87 | // Always ask git for plain tar: gzip is applied here so the pointer rewrite | |
| 73 | 88 | // can see the entries. The gzip header carries no name or time, so the bytes | |
| 74 | 89 | // stay a function of the tag. | |
| 75 | args := []string{"archive", "--format=tar"} | ||
| 76 | if prefix != "" { | ||
| 77 | args = append(args, "--prefix="+prefix) | ||
| 78 | } | ||
| 79 | args = append(args, rev) | ||
| 90 | args := archiveArgs("tar", rev, prefix) | ||
| 80 | 91 | cmd := r.command(args...) | |
| 81 | 92 | var errb bytes.Buffer | |
| 82 | 93 | cmd.Stderr = &errb | |