package repoarchive // import "git.griefed.de/griefed/repoman/internal/repoarchive"
Package repoarchive produces downloadable, restorable backups of the Git
repositories repoman has synced into Forgejo.
Each archive is a complete all-refs bare mirror — every branch, tag, and commit
— cloned with the pure-Go go-git library and packaged as a .zip, so an admin can
keep an off-platform copy that is independent of both Forgejo and the original
source forges. Unzipping an archive yields a bare repository that `git clone`
restores in full.
go-git is used (rather than shelling out to the git binary) to keep repoman a
single static, CGO-free binary with no host tooling dependency. go-git has no
native git-bundle writer, so the mirror is delivered as a zip of the bare repo
instead of a .bundle — the contents are equivalent (all objects and refs).
TYPES
type Archiver struct {
// Has unexported fields.
}
Archiver mirror-clones repositories and packages them as zip archives.
workDir is the base directory for transient bare clones (the service
data directory, so the temporary mirror lands on the same filesystem with
restrictive permissions); an empty workDir falls back to the system temp
dir.
func NewArchiver(workDir string, skipTLS bool) *Archiver
NewArchiver constructs an Archiver rooted at workDir. When skipTLS is true
it installs a certificate-skipping HTTPS transport for go-git (dev only).
func (a *Archiver) WriteRepoZip(ctx context.Context, w io.Writer, spec RepoSpec) error
WriteRepoZip mirror-clones spec into a transient bare repo (all refs) and
streams it as a zip to w. The zip's entries are the bare repo's files,
so unzipping yields a complete clonable Git repository. The temporary clone
is always removed before returning.
type RepoSpec struct {
// CloneURL is the full HTTPS clone URL, e.g.
// https://git.example.com/owner/repo.git.
CloneURL string
// Token is the Forgejo access token used as the basic-auth credential.
// Empty clones anonymously (public repos only).
Token string
// Label is a human-readable identifier used only in error messages.
Label string
}
RepoSpec identifies one repository to mirror.