Documentation
¶
Index ¶
- Constants
- func CanonicalTreeURL(source Source) string
- func ChoosePackagePrefix(paths map[string]struct{}, blobPath string, ...) (string, bool)
- func CollectRepoRelativePaths(archive io.Reader) (map[string]struct{}, error)
- func DownloadTarball(ctx context.Context, client *http.Client, owner, repo, sha string) ([]byte, error)
- func ExtractTarballWithPrefix(archive io.Reader, prefix, destination string) (int, error)
- func LinkStaysInside(relative, target string) bool
- func NormalizedIdentity(source Source, commit string) string
- func ParentDirInRepo(inRepoPath string) string
- func PathLooksLikeFile(inRepoPath string) bool
- func ReadRepoFiles(archive io.Reader, names ...string) (map[string][]byte, error)
- func RepoFile(ctx context.Context, client *http.Client, owner, repo, path string, ...) ([]byte, error)
- func ResolveRef(ctx context.Context, client *http.Client, owner, repo, gitRef string, ...) (string, error)
- func ReuseTarballs(ctx context.Context) context.Context
- type Latest
- type Source
- type Tag
Constants ¶
const ( Host = "github.com" DefaultGitRef = "HEAD" )
Variables ¶
This section is empty.
Functions ¶
func CanonicalTreeURL ¶
func ChoosePackagePrefix ¶
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 LinkStaysInside ¶
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 ParentDirInRepo ¶
func PathLooksLikeFile ¶
func ReadRepoFiles ¶
ReadRepoFiles returns the contents of the named repository-relative files that the archive holds.
func RepoFile ¶ added in v0.14.1
func RepoFile(ctx context.Context, client *http.Client, owner, repo, path string, ttl time.Duration) ([]byte, error)
RepoFile reads one file from a repository's default branch, cached in index.db for ttl. A failed refresh falls back to the cached copy. shortcut: the contents API inlines files up to 1 MB only; switch to the raw media type if a catalog file outgrows that.
func ResolveRef ¶
func ReuseTarballs ¶ added in v0.13.0
ReuseTarballs makes DownloadTarball keep each archive it fetches for ctx: a resolve walks sibling paths of one repository, and each would otherwise download the whole repository again. Callers only read the bytes.
Types ¶
type Latest ¶ added in v0.12.6
type Latest struct {
Commit string `json:"commit"`
CommittedAt string `json:"committed_at,omitempty"`
Current []string `json:"current"`
// False when GitHub's API was unavailable: Commit is the repository's HEAD, which may not touch this folder.
Exact bool `json:"exact"`
}
Latest is the newest version of a package. Current lists the given pins that already hold it: a pin newer than the last commit touching the package's folder has the same files, so it is not behind.
func LatestVersion ¶ added in v0.12.6
func LatestVersion(ctx context.Context, client *http.Client, owner, repo, path string, pins []string) (Latest, error)
LatestVersion asks GitHub for the last commit that changed a package. With the API rate limited or unreachable it falls back to the repository's HEAD over the Git protocol.