go.bigb.es/curator

v1.3.1
Doc Versions Source

Functions

f func AuthMethodFromCredential

src
func AuthMethodFromCredential(credType, data string) (transport.AuthMethod, error)

AuthMethodFromCredential builds a transport.AuthMethod from credential type and JSON data.

f func CommitInfo

src
func CommitInfo(repoPath, rev string) (hash string, t time.Time, err error)

CommitInfo returns the full commit hash and commit time for any git ref.

f func FilterTagsByMajor

src
func FilterTagsByMajor(tags []string, modulePath string) []string

FilterTagsByMajor returns only the tags that match the given module path's major version.

f func LatestRelease

src
func LatestRelease(tags []string) string

LatestRelease returns the highest non-prerelease version from a sorted list.

f func LatestTag

src
func LatestTag(repoPath, rev string) string

LatestTag returns the most recent semver tag reachable from a commit.

f func ListFiles

src
func ListFiles(repoPath, rev string) ([]string, error)

ListFiles returns all file paths at a revision.

f func ListSubDirs

src
func ListSubDirs(repoPath, rev, dir string) ([]string, error)

ListSubDirs returns directories within a path that contain .go files.

f func ListTags

src
func ListTags(repoPath string) ([]string, error)

ListTags returns all valid semver tags from the repository, sorted.

f func LsRemote

src
func LsRemote(repoURL string, auth transport.AuthMethod) error

LsRemote checks that a git repository is accessible. If auth is non-nil, it is used for authentication.

f func MajorForModule

src
func MajorForModule(modulePath string) string

MajorForModule extracts the major version that a module path expects.

f func MatchesMajor

src
func MatchesMajor(tag, major string) bool

MatchesMajor reports whether a semver tag matches the expected major version.

f func ReadDir

src
func ReadDir(repoPath, rev, dir string) (map[string][]byte, error)

ReadDir reads all .go files (excluding test files) from a directory at a revision.

f func ReadFile

src
func ReadFile(repoPath, rev, filePath string) ([]byte, error)

ReadFile reads a file from a git revision.

Types

T type Cache

src
type Cache struct {
	// contains filtered or unexported fields
}

Cache manages bare git clones with a mutex to serialize clone/fetch operations.

f func NewCache

src
func NewCache(dir string) *Cache

m func (*Cache) CloneOrFetch

src
func (c *Cache) CloneOrFetch(name, repoURL string, auth transport.AuthMethod) (string, error)

CloneOrFetch clones the repo if not cached, otherwise fetches new tags. If auth is non-nil, it is used for authentication.

m func (*Cache) Dir

src
func (c *Cache) Dir() string

Dir returns the cache directory path.

T type ResolvedVersion

src
type ResolvedVersion struct {
	Version string // canonical semver (tag or pseudo-version)
	GitRev  string // git revision to pass to git commands (tag name or full hash)
}

ResolvedVersion holds the canonical version string and the git revision to use.

f func ResolveVersion

src
func ResolveVersion(repoPath, query string) (*ResolvedVersion, error)

ResolveVersion determines the canonical version and git revision for a version query. It handles:

  • Tagged versions: v1.0.0 -> use as-is
  • Pseudo-versions: v0.0.0-20240101120000-abcdef123456 -> extract commit hash
  • Raw commits/branches: abcdef123456 or main -> resolve to pseudo-version

T type TreeEntry

src
type TreeEntry struct {
	Name  string
	IsDir bool
}

TreeEntry represents a file or directory in a git tree.

f func ListTree

src
func ListTree(repoPath, rev, dir string) ([]TreeEntry, error)

ListTree lists files and directories at a specific path in a revision.

Source Files