go.bigb.es/curator
Index
- func AuthMethodFromCredential(credType, data string) (transport.AuthMethod, error)
- func CommitInfo(repoPath, rev string) (hash string, t time.Time, err error)
- func FilterTagsByMajor(tags []string, modulePath string) []string
- func LatestRelease(tags []string) string
- func LatestTag(repoPath, rev string) string
- func ListFiles(repoPath, rev string) ([]string, error)
- func ListSubDirs(repoPath, rev, dir string) ([]string, error)
- func ListTags(repoPath string) ([]string, error)
- func LsRemote(repoURL string, auth transport.AuthMethod) error
- func MajorForModule(modulePath string) string
- func MatchesMajor(tag, major string) bool
- func ReadDir(repoPath, rev, dir string) (map[string][]byte, error)
- func ReadFile(repoPath, rev, filePath string) ([]byte, error)
- type Cache
- type ResolvedVersion
- type TreeEntry
Functions
func AuthMethodFromCredential(credType, data string) (transport.AuthMethod, error)
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.
func FilterTagsByMajor(tags []string, modulePath string) []string
FilterTagsByMajor returns only the tags that match the given module path's major version.
func LatestRelease(tags []string) string
LatestRelease returns the highest non-prerelease version from a sorted list.
func LatestTag(repoPath, rev string) string
LatestTag returns the most recent semver tag reachable from a commit.
func ListFiles(repoPath, rev string) ([]string, error)
ListFiles returns all file paths at a revision.
func ListSubDirs(repoPath, rev, dir string) ([]string, error)
ListSubDirs returns directories within a path that contain .go files.
func ListTags(repoPath string) ([]string, error)
ListTags returns all valid semver tags from the repository, sorted.
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.
func MajorForModule(modulePath string) string
MajorForModule extracts the major version that a module path expects.
func MatchesMajor(tag, major string) bool
MatchesMajor reports whether a semver tag matches the expected major version.
func ReadDir(repoPath, rev, dir string) (map[string][]byte, error)
ReadDir reads all .go files (excluding test files) from a directory at a revision.
Types
type Cache struct { // contains filtered or unexported fields }
Cache manages bare git clones with a mutex to serialize clone/fetch operations.
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.
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.
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
AuthMethodFromCredential builds a transport.AuthMethod from credential type and JSON data.