Documentation
¶
Index ¶
- func ComputeNextVersion(current *Version, commits []ParsedCommit) (*Version, BumpType)
- func ExtractBreakingChanges(commits []ParsedCommit) []string
- func GenerateChangelog(commits []ParsedCommit, opts *ChangelogOptions) (string, error)
- func GenerateChangelogPreview(commits []ParsedCommit, nextVersion string) (string, error)
- func GetCommitStats(commits []ParsedCommit) map[string]int
- func GetCommitsSinceTag(repo *git.Repository, tagName string, toRef string, firstParent bool) ([]*object.Commit, error)
- func GetRepositoryName(repo *git.Repository) string
- func GroupCommitsByType(commits []ParsedCommit) map[string][]ParsedCommit
- func OpenRepository(path string) (*git.Repository, error)
- func ValidateMode(mode ReleaseMode) error
- type BumpType
- type ChangelogData
- type ChangelogGroup
- type ChangelogGroupJSON
- type ChangelogJSON
- type ChangelogOptions
- type CommitJSON
- type CommitTypeInfo
- type CutOptions
- type CutResult
- type FileMutation
- type ParsedCommit
- type PlanOptions
- type PublishOptions
- type PublishResult
- type ReleaseMode
- type ReleasePlan
- type ReleaseService
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeNextVersion ¶
func ComputeNextVersion(current *Version, commits []ParsedCommit) (*Version, BumpType)
ComputeNextVersion determines the next version based on commit types
func ExtractBreakingChanges ¶
func ExtractBreakingChanges(commits []ParsedCommit) []string
ExtractBreakingChanges extracts breaking change descriptions from commits
func GenerateChangelog ¶
func GenerateChangelog(commits []ParsedCommit, opts *ChangelogOptions) (string, error)
GenerateChangelog creates a changelog preview from commits
func GenerateChangelogPreview ¶
func GenerateChangelogPreview(commits []ParsedCommit, nextVersion string) (string, error)
GenerateChangelogPreview creates a brief changelog preview suitable for release plan output Returns an error if changelog generation fails instead of embedding error in string
func GetCommitStats ¶
func GetCommitStats(commits []ParsedCommit) map[string]int
GetCommitStats returns statistics about the commits
func GetCommitsSinceTag ¶
func GetCommitsSinceTag(repo *git.Repository, tagName string, toRef string, firstParent bool) ([]*object.Commit, error)
GetCommitsSinceTag returns all commits since the given tag (or from beginning if tagName is empty) if firstParent is true, only follows first parent in merge commits toRef specifies the target ref (defaults to HEAD if empty)
func GetRepositoryName ¶
func GetRepositoryName(repo *git.Repository) string
GetRepositoryName attempts to extract the repository name from remote URL
func GroupCommitsByType ¶
func GroupCommitsByType(commits []ParsedCommit) map[string][]ParsedCommit
GroupCommitsByType groups commits by their type for changelog generation
func OpenRepository ¶
func OpenRepository(path string) (*git.Repository, error)
OpenRepository opens a git repository at the given path
func ValidateMode ¶
func ValidateMode(mode ReleaseMode) error
ValidateMode checks that a ReleaseMode string is one of the allowed values.
Types ¶
type ChangelogData ¶
type ChangelogData struct {
Version string
BreakingChanges []string
Groups []ChangelogGroup
}
ChangelogData contains data for changelog template rendering
type ChangelogGroup ¶
type ChangelogGroup struct {
Type string
Info CommitTypeInfo
Commits []ParsedCommit
}
ChangelogGroup represents a group of commits in the changelog
type ChangelogGroupJSON ¶
type ChangelogGroupJSON struct {
Type string `json:"type"`
Name string `json:"name"`
Commits []CommitJSON `json:"commits"`
}
ChangelogGroupJSON represents a commit group in JSON output
type ChangelogJSON ¶
type ChangelogJSON struct {
Version string `json:"version,omitempty"`
BreakingChanges []string `json:"breaking_changes,omitempty"`
Groups []ChangelogGroupJSON `json:"groups"`
Stats map[string]int `json:"stats"`
}
ChangelogJSON represents the JSON output format for changelog generation
func GenerateChangelogJSON ¶
func GenerateChangelogJSON(commits []ParsedCommit, opts *ChangelogOptions) *ChangelogJSON
GenerateChangelogJSON creates a structured JSON changelog from commits
type ChangelogOptions ¶
type ChangelogOptions struct {
// version being released
Version string
// include non-releasable commit types
IncludeAll bool
// custom template (uses default if empty)
Template string
}
ChangelogOptions contains options for changelog generation
type CommitJSON ¶
type CommitJSON struct {
Hash string `json:"hash"`
Type string `json:"type"`
Scope string `json:"scope,omitempty"`
Subject string `json:"subject"`
Breaking bool `json:"breaking,omitempty"`
}
CommitJSON represents a single commit in JSON output
type CommitTypeInfo ¶
CommitTypeInfo defines properties for a commit type
func GetCommitTypeInfo ¶
func GetCommitTypeInfo(commitType string) CommitTypeInfo
GetCommitTypeInfo returns info for a commit type, or a default if unknown
type CutOptions ¶
type CutOptions struct {
RepoPath string // path to git repo (default ".")
Branch string // expected branch (default "main")
Remote string // git remote name (default "origin")
PlanFile string // path to pre-generated plan JSON/YAML
MutationsConfig string // path to mutations config file
DryRun bool // show what would happen without side effects
Publish bool // create published release directly (no draft)
Mode ReleaseMode // "auto" (default), "api", "local"
CommitAuthor string // bot commit author name
CommitEmail string // bot commit author email
Token string // GitHub token for API and push
ReleaseAPI ReleaseService // optional; created from Token if nil
}
CutOptions contains configuration for executing a release cut
func DefaultCutOptions ¶
func DefaultCutOptions() *CutOptions
DefaultCutOptions returns options with sensible defaults
type CutResult ¶
type CutResult struct {
TagName string `json:"tag_name"`
Version string `json:"version"`
CommitSHA string `json:"commit_sha"`
ReleaseURL string `json:"release_url,omitempty"`
ReleaseID int64 `json:"release_id,omitempty"`
Draft bool `json:"draft"`
Published bool `json:"published"`
FilesModified []string `json:"files_modified,omitempty"`
DryRun bool `json:"dry_run"`
NoRelease bool `json:"no_release"`
Reason string `json:"reason,omitempty"`
}
CutResult captures the outcome of a release cut
func ExecuteCut ¶
func ExecuteCut(opts *CutOptions) (*CutResult, error)
ExecuteCut orchestrates the full release cut flow
type FileMutation ¶
type FileMutation struct {
Path string `json:"path" yaml:"path"`
Type string `json:"type" yaml:"type"` // jsonPath, yamlPath, regex
Field string `json:"field" yaml:"field"` // field being modified
OldValue string `json:"old_value" yaml:"old_value"` // current value
NewValue string `json:"new_value" yaml:"new_value"` // value after release
}
FileMutation represents a file change that would occur during release
type ParsedCommit ¶
type ParsedCommit struct {
Hash string `json:"hash" yaml:"hash"`
Type string `json:"type" yaml:"type"` // feat, fix, docs, etc.
Scope string `json:"scope,omitempty" yaml:"scope,omitempty"` // optional scope
Subject string `json:"subject" yaml:"subject"` // commit subject line
Body string `json:"body,omitempty" yaml:"body,omitempty"` // optional body
Breaking bool `json:"breaking" yaml:"breaking"` // is this a breaking change?
Raw string `json:"raw" yaml:"raw"` // original commit message
}
ParsedCommit represents a parsed conventional commit
func FilterReleasableCommits ¶
func FilterReleasableCommits(commits []ParsedCommit) []ParsedCommit
FilterReleasableCommits returns only commits that trigger a version bump
func ParseCommits ¶
func ParseCommits(commits []*object.Commit) []ParsedCommit
ParseCommits converts git commits to ParsedCommits non-conventional commits are included with Type="other"
func ParseConventionalCommit ¶
func ParseConventionalCommit(hash, message string) *ParsedCommit
ParseConventionalCommit parses a commit message into a ParsedCommit returns nil if the message doesn't follow conventional commit format
type PlanOptions ¶
type PlanOptions struct {
// base ref to compare from (default: latest tag)
FromRef string
// target ref to compare to (default: HEAD)
ToRef string
// only follow first parent in merge commits
FirstParent bool
// path to repository (default: current directory)
RepoPath string
// output format (text, json, yaml)
OutputFormat string
// path to mutations config file (optional)
MutationsConfig string
// release mode: "auto" (default), "api", "local"
Mode ReleaseMode
// GitHub API client for API mode tag/commit discovery (optional)
ReleaseAPI ReleaseService
// branch name used as head for API compare (required for API mode)
Branch string
}
PlanOptions contains options for generating a release plan
func DefaultPlanOptions ¶
func DefaultPlanOptions() *PlanOptions
DefaultPlanOptions returns options with sensible defaults
type PublishOptions ¶
type PublishOptions struct {
RepoPath string // path to git repo (for remote detection)
Tag string // specific tag to publish (mutually exclusive with Latest and ReleaseID)
Latest bool // find latest draft (mutually exclusive with Tag and ReleaseID)
ReleaseID int64 // publish by numeric release ID — works with GitHub App tokens
// Note: --tag and --latest require a user token; GitHub App tokens cannot discover
// draft releases via list/search endpoints. Use --release-id for App token workflows.
Token string // GitHub token (required)
DryRun bool // preview only, don't publish
ReleaseAPI ReleaseService // optional; created from Token if nil
}
PublishOptions contains configuration for publishing a draft release
type PublishResult ¶
type PublishResult struct {
TagName string `json:"tag_name"`
ReleaseURL string `json:"release_url"`
ReleaseID int64 `json:"release_id"`
Published bool `json:"published"` // always true on success
DryRun bool `json:"dry_run"`
}
PublishResult captures the outcome of a release publish
func ExecutePublish ¶
func ExecutePublish(opts *PublishOptions) (*PublishResult, error)
ExecutePublish orchestrates the full release publish flow
func (*PublishResult) ToJSON ¶
func (r *PublishResult) ToJSON() ([]byte, error)
ToJSON serializes the publish result to JSON
type ReleaseMode ¶
type ReleaseMode string
ReleaseMode controls how autogov performs git read operations
const ( ModeAuto ReleaseMode = "auto" // use API if token present; fall back to local on error ModeAPI ReleaseMode = "api" // require GitHub API, fail hard on error ModeLocal ReleaseMode = "local" // use local go-git only (offline) )
type ReleasePlan ¶
type ReleasePlan struct {
// metadata
GeneratedAt time.Time `json:"generated_at" yaml:"generated_at"`
Repository string `json:"repository" yaml:"repository"`
// version info
CurrentVersion string `json:"current_version" yaml:"current_version"`
NextVersion string `json:"next_version" yaml:"next_version"`
BumpType string `json:"bump_type" yaml:"bump_type"` // major/minor/patch/none
// commits
Commits []ParsedCommit `json:"commits" yaml:"commits"`
BreakingChanges []string `json:"breaking_changes" yaml:"breaking_changes"`
// changelog
ChangelogPreview string `json:"changelog_preview" yaml:"changelog_preview"`
// file mutations (placeholder for Story 2.3)
FileMutations []FileMutation `json:"file_mutations,omitempty" yaml:"file_mutations,omitempty"`
// status
ReleaseNeeded bool `json:"release_needed" yaml:"release_needed"`
Reason string `json:"reason,omitempty" yaml:"reason,omitempty"`
}
ReleasePlan contains all information about a planned release
func GeneratePlan ¶
func GeneratePlan(opts *PlanOptions) (*ReleasePlan, error)
GeneratePlan generates a complete release plan
func (*ReleasePlan) ToJSON ¶
func (p *ReleasePlan) ToJSON() ([]byte, error)
ToJSON converts the plan to JSON format
func (*ReleasePlan) ToText ¶
func (p *ReleasePlan) ToText() string
ToText converts the plan to human-readable text format
func (*ReleasePlan) ToYAML ¶
func (p *ReleasePlan) ToYAML() ([]byte, error)
ToYAML converts the plan to YAML format
type ReleaseService ¶
type ReleaseService interface {
// release operations
GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*gogithub.RepositoryRelease, *gogithub.Response, error)
GetRelease(ctx context.Context, owner, repo string, id int64) (*gogithub.RepositoryRelease, *gogithub.Response, error)
CreateRelease(ctx context.Context, owner, repo string, release *gogithub.RepositoryRelease) (*gogithub.RepositoryRelease, *gogithub.Response, error)
UpdateRelease(ctx context.Context, owner, repo string, id int64, release *gogithub.RepositoryRelease) (*gogithub.RepositoryRelease, *gogithub.Response, error)
ListReleases(ctx context.Context, owner, repo string, opts *gogithub.ListOptions) ([]*gogithub.RepositoryRelease, *gogithub.Response, error)
// read operations (tag discovery, commit comparison, branch validation)
ListTags(ctx context.Context, owner, repo string, opts *gogithub.ListOptions) ([]*gogithub.RepositoryTag, *gogithub.Response, error)
CompareCommits(ctx context.Context, owner, repo, base, head string, opts *gogithub.ListOptions) (*gogithub.CommitsComparison, *gogithub.Response, error)
GetBranch(ctx context.Context, owner, repo, branch string, maxRedirects int) (*gogithub.Branch, *gogithub.Response, error)
// git data operations (commits/tags created via API are auto-signed by GitHub per SLSA v1.2)
CreateTree(ctx context.Context, owner, repo, baseTree string, entries []*gogithub.TreeEntry) (*gogithub.Tree, *gogithub.Response, error)
CreateCommit(ctx context.Context, owner, repo string, commit gogithub.Commit, opts *gogithub.CreateCommitOptions) (*gogithub.Commit, *gogithub.Response, error)
CreateTag(ctx context.Context, owner, repo string, tag gogithub.CreateTag) (*gogithub.Tag, *gogithub.Response, error)
CreateRef(ctx context.Context, owner, repo string, ref gogithub.CreateRef) (*gogithub.Reference, *gogithub.Response, error)
UpdateRef(ctx context.Context, owner, repo, ref string, updateRef gogithub.UpdateRef) (*gogithub.Reference, *gogithub.Response, error)
}
ReleaseService abstracts GitHub API operations for testability
type Version ¶
Version represents a semantic version
func DiscoverLatestTag ¶
DiscoverLatestTag finds the most recent semver tag in the repository if firstParent is true, only considers tags that are ancestors of HEAD via first-parent
func ParseVersion ¶
ParseVersion parses a semver string into a Version struct accepts formats: v1.2.3, 1.2.3, v1.2.3-rc.1, 1.2.3+build.123
func (*Version) Compare ¶
Compare compares two versions: returns -1 if v < other, 0 if equal, 1 if v > other
func (*Version) StringWithoutV ¶
StringWithoutV returns the version as a string without v prefix