gitfs

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0, BSD-3-Clause Imports: 16 Imported by: 0

README

Package gitfs presents a file tree downloaded from a remote Git repo as an in-memory fs.FS. See the API reference.

Documentation

Overview

Package gitfs presents a file tree downloaded from a remote Git repo as an in-memory fs.FS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirEntry

type DirEntry struct {
	Mode int
	Name []byte
	Hash Hash
}

A DirEntry is a Git directory entry parsed from a tree object.

type Hash

type Hash [20]byte

A Hash is a SHA-1 Hash identifying a particular Git object.

func ParseHash

func ParseHash(text string) (Hash, error)

ParseHash parses the (full-length) Git hash text.

func (Hash) String

func (h Hash) String() string

type ObjType

type ObjType int

An ObjType is an object type indicator. The values are the ones used in Git pack encoding (https://git-scm.com/docs/pack-format#_object_types).

func (ObjType) String

func (t ObjType) String() string

type Ref

type Ref struct {
	Name string // "refs/heads/main", "refs/tags/v1.0.0", "HEAD"
	Hash Hash   // hexadecimal hash
}

A Ref is a single Git reference, like refs/heads/main, refs/tags/v1.0.0, or HEAD.

type Repo

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

A Repo is a connection to a remote repository served over HTTP or HTTPS.

func NewRepo

func NewRepo(ctx context.Context, url string) (*Repo, error)

NewRepo connects to a Git repository at the given http:// or https:// URL.

func (*Repo) Clone

func (r *Repo) Clone(ctx context.Context, ref string) (Hash, fs.FS, error)

Clone resolves the given ref to a hash and returns the corresponding fs.FS.

func (*Repo) CloneHash

func (r *Repo) CloneHash(ctx context.Context, h Hash) (fs.FS, []byte, error)

CloneHash returns the fs.FS for the given hash.

func (*Repo) Handshake

func (r *Repo) Handshake(ctx context.Context) error

Handshake runs the initial Git opening Handshake, learning the capabilities of the server. See https://git-scm.com/docs/protocol-v2#_initial_client_request.

func (*Repo) Refs

func (r *Repo) Refs(ctx context.Context, prefixes ...string) ([]Ref, error)

Refs executes an ls-Refs command on the remote server to look up Refs with the given prefixes. See https://git-scm.com/docs/protocol-v2#_ls_refs.

func (*Repo) Resolve

func (r *Repo) Resolve(ctx context.Context, ref string) (Hash, error)

Resolve looks up the given ref and returns the corresponding Hash.

Jump to

Keyboard shortcuts

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