go.bigb.es/curator
Index
- 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 ListSubDirs(repoPath, rev, dir string) ([]string, error)
- func ListTags(repoPath string) ([]string, 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 CommitInfo(repoPath, rev string) (hash string, t time.Time, err error)
func FilterTagsByMajor(tags []string, modulePath string) []string
FilterTagsByMajor returns only the tags that match the given module path's major version. For a module without a /vN suffix, only v0 and v1 tags are returned. For a module ending in /v2, only v2 tags are returned, etc.
func LatestRelease(tags []string) string
LatestRelease returns the highest non-prerelease version from a sorted list of tags. If no release version exists, it falls back to the highest tag. This matches Go's @latest behavior: prefer stable releases over pre-releases.
func LatestTag(repoPath, rev string) string
LatestTag returns the most recent semver tag reachable from a commit, or "" if none exists.
func ListSubDirs(repoPath, rev, dir string) ([]string, error)
ListSubDirs returns directories within a path that contain .go files (i.e., Go packages).
func ListTags(repoPath string) ([]string, error)
ListTags returns all valid semver tags from the repository, sorted.
func MajorForModule(modulePath string) string
MajorForModule extracts the major version that a module path expects. "foo/bar" → "v0v1", "foo/bar/v2" → "v2", "foo/bar/v3" → "v3".
func MatchesMajor(tag, major string) bool
MatchesMajor reports whether a semver tag matches the expected major version. major is either "v0v1" (for unversioned module paths) or "vN".
func ReadDir(repoPath, rev, dir string) (map[string][]byte, error)
ReadDir reads all .go files (excluding test files) from a directory at a revision. Returns a map of filename to contents.
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) (string, error)
CloneOrFetch clones the repo if not cached, otherwise fetches new tags.
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
CommitInfo returns the full commit hash and commit time for any git ref.