go.bigb.es/curator

v1.0.0
Doc Versions Source

Functions

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. 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.

f func LatestRelease

src
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.

f func LatestTag

src
func LatestTag(repoPath, rev string) string

LatestTag returns the most recent semver tag reachable from a commit, or "" if none exists.

f func ListSubDirs

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

ListSubDirs returns directories within a path that contain .go files (i.e., Go packages).

f func ListTags

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

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

f func MajorForModule

src
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".

f func MatchesMajor

src
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".

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. Returns a map of filename to contents.

f func ReadFile

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

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) (string, error)

CloneOrFetch clones the repo if not cached, otherwise fetches new tags.

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