gitfetch

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package gitfetch fetches directory trees from git repositories using sparse checkout, providing a forge-agnostic alternative to REST API directory listing.

Index

Constants

View Source
const (
	MaxFiles = 1000
)

Variables

This section is empty.

Functions

func FetchTree

func FetchTree(ctx context.Context, cloneURL, subpath, ref, token string) (map[string][]byte, error)

FetchTree fetches all files under path in a repository at ref using git sparse checkout. It creates a temporary shallow clone with only tree objects, configures sparse checkout for the target path, then reads the materialized files from disk.

The token is sent only to the configured GitHub forge's origin: the host in GITHUB_SERVER_URL (forge.ConfiguredGitHubURL), or github.com when it is unset. Any other clone origin, a GitLab or Forgejo host included, is fetched anonymously. This is a deliberate exception to the forge-agnostic description of this package in ADR 0005 and ADR 0038: the only token callers pass today comes from the GitHub credential chain, and FetchTree is the one place every token-bearing tree fetch (fetchsvc, resolve, harness composition) passes through, so the check lives here rather than at each caller.

Types

type TransientError

type TransientError struct {
	Err error
}

TransientError wraps errors caused by temporary network conditions (DNS failures, connection refused, etc.) detected from git stderr.

func (*TransientError) Error

func (e *TransientError) Error() string

func (*TransientError) Unwrap

func (e *TransientError) Unwrap() error

type TreeFetchFunc

type TreeFetchFunc func(ctx context.Context, cloneURL, path, ref, token string) (map[string][]byte, error)

TreeFetchFunc fetches all files under path in a repository at ref. Returns map[relativePath]content. Token is optional — when empty the fetch is unauthenticated (sufficient for public repos).

Jump to

Keyboard shortcuts

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