mirror

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package mirror manages bare git mirrors on disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoteSha

func RemoteSha(ctx context.Context, url, branch string, sshEnv []string) (string, error)

Returns the current HEAD sha for a branch via git ls-remote. Returns an empty string when the branch does not exist on the remote.

func SshEnv

func SshEnv(privateKeyFile, knownHostsFile, hostKeyPolicy string) []string

Builds the GIT_SSH_COMMAND environment slice for git operations.

Types

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

func Find

func Find(url, dataPath string, sshEnv []string, logger *slog.Logger) (*Repo, error)

Returns an existing local mirror for url, or nil if it has not been cloned yet.

func Open

func Open(ctx context.Context, url, dataPath string, sshEnv []string, logger *slog.Logger) (*Repo, error)

Returns a repo for url, cloning it as a bare mirror if it does not exist yet.

func (*Repo) DiffFiles

func (repo *Repo) DiffFiles(ctx context.Context, oldSha, newSha string) ([]string, error)

Returns the list of files changed between two commits.

func (*Repo) EnsureCommit

func (repo *Repo) EnsureCommit(ctx context.Context, sha string) error

Guarantees that the sha is present in the local mirror.

func (*Repo) HasCommit

func (repo *Repo) HasCommit(ctx context.Context, sha string) bool

Reports whether sha exists in the local mirror.

func (*Repo) IsAncestor

func (repo *Repo) IsAncestor(ctx context.Context, ancestor, descendant string) bool

IsAncestor reports whether ancestor is reachable from descendant in the local mirror.

func (*Repo) ListFiles

func (repo *Repo) ListFiles(ctx context.Context, sha, path string) ([]string, error)

Returns the paths of all files under path at the given commit.

func (*Repo) LocalHead

func (repo *Repo) LocalHead(branch string) (string, error)

Returns the sha that the given branch points to in the local mirror.

func (*Repo) ReadFile

func (repo *Repo) ReadFile(ctx context.Context, sha, filePath string) ([]byte, error)

Returns the contents of filePath at the given commit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL