Documentation
¶
Index ¶
- func FileAddedAt(repoRoot, path string) (time.Time, bool)
- func FileAddedMeta(repoRoot, path string) (time.Time, string, string, bool)
- func FileAddedMetaMany(repoRoot string, paths []string) map[string]FileMetaResult
- func FindAllChangesDirs(root string) ([]string, error)
- func FindGitRoot(startPath string) (string, bool, error)
- func HasAbbreviatedVersionTags(repoRoot, tagPrefix string) (bool, error)
- func IsWithinDir(parent, target string) bool
- func ListSemVerTags(repoRoot string, tagPrefix string) ([]semver.Tag, error)
- func RunGit(dir string, args ...string) (string, error)
- func RunGitWithContext(ctx context.Context, dir string, args ...string) (string, error)
- func SplitLines(s string) []string
- type FileMetaResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileAddedAt ¶
FileAddedAt returns the author date of the commit that first introduced the file at path in the repository at repoRoot. The path may be absolute; it is made relative to repoRoot before being passed to git so that --follow works correctly. The second return value is false when the file has no recorded git history (untracked, or git unavailable).
func FileAddedMeta ¶
FileAddedMeta returns metadata for the commit that first introduced path, following renames to preserve original attribution.
func FileAddedMetaMany ¶
func FileAddedMetaMany(repoRoot string, paths []string) map[string]FileMetaResult
FileAddedMetaMany returns add metadata for multiple files using a single git log call. This avoids the O(N) subprocess overhead of calling FileAddedMeta per file. Paths may be absolute; the returned map key is the original path. Files missing from the result (e.g. untracked or renamed) should fall back to per-file FileAddedMeta for --follow semantics.
func FindAllChangesDirs ¶
FindAllChangesDirs recursively finds all ".changes" directories under root. It does not recurse into ".git" directories or into ".changes" directories themselves (nested ".changes" hierarchies are not supported). All returned paths are guaranteed to be within root.
func FindGitRoot ¶
FindGitRoot walks up from startPath until it finds a directory that contains a ".git" entry. It returns the root path and true when found. If the filesystem root is reached without finding ".git", it returns startPath and false.
func HasAbbreviatedVersionTags ¶
HasAbbreviatedVersionTags reports whether the repository at repoRoot contains any abbreviated major (e.g. v1) or major.minor (e.g. v1.2) tags with the given prefix. Used to auto-detect the alias-tags release policy.
func IsWithinDir ¶
IsWithinDir reports whether target is inside (or equal to) parent. Both paths must be absolute and are cleaned before comparison.
func ListSemVerTags ¶
ListSemVerTags returns every SemVer tag in the repository at repoRoot, optionally scoped by tagPrefix, ordered from oldest to newest by SemVer. When git is unavailable or the repository has no matching tags, an empty slice and no error are returned.
Tag name and date are fetched in a single git call using --format so the number of subprocess invocations is O(1) instead of O(n tags). %(creatordate) gives the commit author date for lightweight tags and the tagger date for annotated tags; both are accurate enough for version attribution ordering.
func RunGitWithContext ¶
RunGitWithContext runs a git command in dir using the provided context for cancellation and deadline control.
func SplitLines ¶
SplitLines splits s into lines, returning nil when s is blank.