github

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Host          = "github.com"
	DefaultGitRef = "HEAD"
)

Variables

This section is empty.

Functions

func CanonicalTreeURL

func CanonicalTreeURL(source Source) string

func ChoosePackagePrefix

func ChoosePackagePrefix(paths map[string]struct{}, blobPath string, packageRoot func(map[string]struct{}, string) bool) (string, bool)

func CollectRepoRelativePaths

func CollectRepoRelativePaths(archive io.Reader) (map[string]struct{}, error)

func DownloadTarball

func DownloadTarball(ctx context.Context, client *http.Client, owner, repo, sha string) ([]byte, error)

DownloadTarball tries anonymous codeload first, authenticated codeload for private repositories second, then the Git protocol. Transient HTTP failures receive the same three-attempt exponential retry policy as other sources.

func ExtractTarballWithPrefix

func ExtractTarballWithPrefix(archive io.Reader, prefix, destination string) (int, error)

func LinkStaysInside

func LinkStaysInside(relative, target string) bool

LinkStaysInside reports whether a symbolic link at relative (inside the extracted tree) may be created as written. The target must be a clean relative path — any ".." only at its start — that still lies inside the tree, so that following it, however links are chained, cannot leave the tree. Every other link (absolute, or reaching a part of the repository that is not extracted) is written as an empty file, as before.

func NormalizedIdentity

func NormalizedIdentity(source Source, commit string) string

func ParentDirInRepo

func ParentDirInRepo(inRepoPath string) string

func PathLooksLikeFile

func PathLooksLikeFile(inRepoPath string) bool

func ReadRepoFiles

func ReadRepoFiles(archive io.Reader, names ...string) (map[string][]byte, error)

ReadRepoFiles returns the contents of the named repository-relative files that the archive holds.

func ResolveRef

func ResolveRef(ctx context.Context, client *http.Client, owner, repo, gitRef string, forceRefresh bool) (string, error)

Types

type Source

type Source struct {
	Owner  string
	Repo   string
	GitRef string
	Path   string
}

func ParseURL

func ParseURL(raw string) (Source, error)

func SourceFromSegments

func SourceFromSegments(owner, repo, inRepoPath string) Source

func SourceFromSegmentsRef

func SourceFromSegmentsRef(owner, repo, inRepoPath, gitRef string) Source

type Tag

type Tag struct {
	Name string `json:"name"`
	SHA  string `json:"sha"`
}

func ListTags

func ListTags(ctx context.Context, client *http.Client, owner, repo string, forceRefresh bool) ([]Tag, error)

Jump to

Keyboard shortcuts

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