Documentation
¶
Overview ¶
Package vcs abstracts the version-control operations releasegen needs.
The Repo interface is defined here in the consumer package per Go best practice. The default implementation is GitRepo (in git.go), which uses go-git. Tests use mockery-generated mocks under internal/vcs/mocks.
Index ¶
- Variables
- func LatestTagForModule(tags []TagInfo, moduleName string) string
- type CommitTagPushOptions
- type GitRepo
- func (g *GitRepo) AllChangelogPaths(ctx context.Context) ([]string, error)
- func (g *GitRepo) CommitTagAndPush(ctx context.Context, opts CommitTagPushOptions) error
- func (g *GitRepo) IsChangelogModifiedSinceTag(ctx context.Context, changelogPath, tagName string) (bool, error)
- func (g *GitRepo) ReachableTags(ctx context.Context) ([]TagInfo, error)
- type Repo
- type TagInfo
Constants ¶
This section is empty.
Variables ¶
var ErrVCS = errors.New("vcs error")
ErrVCS is the sentinel returned (wrapped) when any git-side operation (open, walk, commit, tag, push) fails. Callers should use errors.Is to branch on it for exit code mapping rather than scanning error strings.
Functions ¶
func LatestTagForModule ¶
LatestTagForModule returns the most recent tag in tags belonging to the named module (empty name = root). It returns "" when no tag is found.
Types ¶
type CommitTagPushOptions ¶
type CommitTagPushOptions struct {
ChangelogPath string
ModuleName string
Version string // bare semver
Actor string
Token string // pushed via basic auth
}
CommitTagPushOptions describes a single per-module commit + tag + push.
type GitRepo ¶
type GitRepo struct {
// contains filtered or unexported fields
}
GitRepo is a Repo implementation backed by go-git operating on an on-disk repository.
func Open ¶
Open opens the git repository at the given path and returns a GitRepo configured for the named release branch.
func (*GitRepo) AllChangelogPaths ¶
AllChangelogPaths walks HEAD's tree and returns every CHANGELOG.md path.
func (*GitRepo) CommitTagAndPush ¶
func (g *GitRepo) CommitTagAndPush(ctx context.Context, opts CommitTagPushOptions) error
CommitTagAndPush stages, commits, pushes, tags, and pushes the tag for a single module release. Errors are wrapped with the failing step name so the caller can decide on recovery.
func (*GitRepo) IsChangelogModifiedSinceTag ¶
func (g *GitRepo) IsChangelogModifiedSinceTag(ctx context.Context, changelogPath, tagName string) (bool, error)
IsChangelogModifiedSinceTag returns true if changelogPath was changed between the commit referenced by tagName and HEAD. When tagName is empty the function returns true (first release).
type Repo ¶
type Repo interface {
// AllChangelogPaths returns every CHANGELOG.md file in HEAD's tree.
AllChangelogPaths(ctx context.Context) ([]string, error)
// ReachableTags returns all tags whose commits are reachable from the
// configured release branch.
ReachableTags(ctx context.Context) ([]TagInfo, error)
// IsChangelogModifiedSinceTag reports whether the file at changelogPath
// has been modified between the commit pointed at by tagName and HEAD.
// When tagName is empty (no prior tag) the function returns true.
IsChangelogModifiedSinceTag(ctx context.Context, changelogPath, tagName string) (bool, error)
// CommitTagAndPush stages the changelog file, commits it with a
// "[skip ci]" message, pushes the commit, creates an annotated tag for
// the release name, and pushes the tag. It is intentionally a single
// operation so the implementation can attempt cleanup on failure.
CommitTagAndPush(ctx context.Context, opts CommitTagPushOptions) error
}
Repo is the abstraction the runner uses to interact with git. It is intentionally tiny so it can be mocked easily.