Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Code

392 commit(s) on main

Merge change request 01M70WES5ZZDJ6RP226WB11BBZ: Let people rename and remove their own passkeys keenan · 22m ago 4b8c9e1d
history blame raw 1.2 KiB
1package git
2
3// Archive streams a tar of a revision. A release tarball is generated this way
4// rather than stored: `git archive` output is a pure function of the revision
5// (entry mtimes come from the commit), so caching it would be an optimisation
6// that cannot serve stale bytes, and skipping the store means a tarball cannot
7// drift from the tag it claims to be. Measured at 54 ms tar / 221 ms tar.gz for
8// a real repository.
9
10import (
11 "bytes"
12 "fmt"
13 "io"
14 "strings"
15)
16
17// Archive writes `git archive --format=<format> <rev>` to w. prefix, when set,
18// is prepended to every path so extraction creates one directory instead of
19// scattering the tree into the current one.
20//
21// The caller owns the response: bytes are written as git produces them, so a
22// failure part-way is a truncated download, not an error this can report.
23func (r *Repo) Archive(w io.Writer, rev, format, prefix string) error {
24 args := []string{"archive", "--format=" + format}
25 if prefix != "" {
26 args = append(args, "--prefix="+prefix)
27 }
28 args = append(args, rev)
29 cmd := r.command(args...)
30 var errb bytes.Buffer
31 cmd.Stderr = &errb
32 cmd.Stdout = w
33 if err := cmd.Run(); err != nil {
34 return fmt.Errorf("archive %s: %w: %s", rev, err, strings.TrimSpace(errb.String()))
35 }
36 return nil
37}
38