workspace

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BumpBatchFingerprint added in v0.0.7

func BumpBatchFingerprint(dir string) (map[string]string, error)

BumpBatchFingerprint hashes the pending bump files, identifying the batch a commit attempt operates on.

func BumpFilename

func BumpFilename(base string, suffix string) string

func CollectBumps added in v0.0.5

func CollectBumps(ctx context.Context, logger *slog.Logger, dir string, cfg *Config, provenance Provenance) (map[string]*ReleaseGroupStatus, error)

CollectBumps composes GatherBumps and SquashBumps: it reads the pending bump files in dir and reduces them to per-group release status.

func CommitCheckpointFilename added in v0.0.7

func CommitCheckpointFilename(base string) string

func ConfigFilename

func ConfigFilename(base string) string

func DeleteBumps added in v0.0.5

func DeleteBumps(ctx context.Context, dir string) error

func DeleteCommitCheckpoint added in v0.0.7

func DeleteCommitCheckpoint(dir string) error

DeleteCommitCheckpoint removes the checkpoint; a missing file is not an error.

func Dir

func Dir(base string) string

func GetCurrentVersion added in v0.0.5

func GetCurrentVersion(ctx context.Context, runner Runner, dir string, group ReleaseGroup) (*semver.Version, error)

func GetNextVersion added in v0.0.5

func GetNextVersion(ctx context.Context, runner Runner, dir string, group ReleaseGroup, level BumpLevel) (string, error)

func GetWd

func GetWd(start string) (wd string, err error)

func Initialize

func Initialize(baseDir string) error

func SaveCommitCheckpoint added in v0.0.7

func SaveCommitCheckpoint(dir string, checkpoint *CommitCheckpoint) error

func SaveConfig

func SaveConfig(baseDir string, cfg *Config) error

func SquashBumps added in v0.0.7

func SquashBumps(ctx context.Context, logger *slog.Logger, bumps []ParsedBump, cfg *Config) map[string]*ReleaseGroupStatus

SquashBumps reduces parsed bump files to per-group release status: the highest bump level wins per group and changelog entries are ordered by commit timestamp. Bumps for groups absent from cfg and entries with unknown levels are skipped with a warning. It touches neither disk nor git.

func VersionFilename

func VersionFilename(base string) string

Types

type BumpLevel

type BumpLevel int
const (
	BumpLevelNone  BumpLevel = 0
	BumpLevelPatch BumpLevel = 1
	BumpLevelMinor BumpLevel = 2
	BumpLevelMajor BumpLevel = 3
)

func (BumpLevel) String

func (b BumpLevel) String() string

type Commit

type Commit struct {
	SHA  string
	When time.Time
}

Commit identifies the commit that introduced a bump file.

type CommitCheckpoint added in v0.0.7

type CommitCheckpoint struct {
	// Batch fingerprints the pending bump files (base name -> content hash)
	// the checkpoint belongs to. A retry with different pending bumps is a
	// different batch and must not reuse this checkpoint.
	Batch map[string]string `toml:"batch"`
	// Released maps release group names to the version released for them in
	// a previous attempt at this batch.
	Released map[string]string `toml:"released"`
}

CommitCheckpoint records the progress of a partially failed `bumper commit` so a retry can skip release groups whose commands already succeeded. It is written after each group completes and removed once the whole batch has been released.

func LoadCommitCheckpoint added in v0.0.7

func LoadCommitCheckpoint(dir string) (*CommitCheckpoint, error)

LoadCommitCheckpoint reads a checkpoint left by a failed commit attempt. It returns nil without error when no checkpoint exists.

type Config

type Config struct {
	Groups []ReleaseGroup `json:"groups,omitempty,omitzero" toml:"groups,omitempty,omitzero" yaml:"groups,omitempty,omitzero"`
}

func LoadConfig

func LoadConfig(baseDir string) (*Config, error)

func (*Config) IndexReleaseGroups

func (c *Config) IndexReleaseGroups() map[string]ReleaseGroup

type ExecRunner added in v0.0.7

type ExecRunner struct{}

ExecRunner runs group commands as child processes with stderr passed through to the parent process.

func (ExecRunner) Run added in v0.0.7

func (ExecRunner) Run(ctx context.Context, dir string, inv GroupInvocation, stdout io.Writer) error

type FakeProvenance added in v0.0.7

type FakeProvenance struct {
	Commits map[string]Commit
}

FakeProvenance serves canned commits from memory so callers can be tested without a git repository.

func (*FakeProvenance) Resolve added in v0.0.7

func (f *FakeProvenance) Resolve(_ context.Context, bumpFiles []string) (map[string]Commit, error)

type FakeRunner added in v0.0.7

type FakeRunner struct {
	Calls  []FakeRunnerCall
	Stdout map[Verb]string
	Err    error
}

FakeRunner records every invocation and plays back canned stdout per verb so callers can be tested without spawning processes.

func (*FakeRunner) Run added in v0.0.7

func (f *FakeRunner) Run(_ context.Context, dir string, inv GroupInvocation, stdout io.Writer) error

type FakeRunnerCall added in v0.0.7

type FakeRunnerCall struct {
	Dir        string
	Invocation GroupInvocation
}

type GitProvenance added in v0.0.7

type GitProvenance struct {
	Logger *slog.Logger
	Dir    string
}

GitProvenance resolves bump-file provenance from the git repository containing Dir, deepening shallow clones as needed. A directory outside any git repository degrades to empty results with a warning.

func NewGitProvenance added in v0.0.7

func NewGitProvenance(logger *slog.Logger, dir string) *GitProvenance

func (*GitProvenance) Resolve added in v0.0.7

func (g *GitProvenance) Resolve(ctx context.Context, bumpFiles []string) (map[string]Commit, error)

type GroupInvocation added in v0.0.7

type GroupInvocation struct {
	Verb Verb
	Argv []string
	Env  []string
}

GroupInvocation is a fully-resolved group command: the argv to execute and the BUMPER_* environment variables that carry the protocol inputs. Env holds KEY=VALUE pairs appended to the parent process environment.

func NewCatInvocation added in v0.0.7

func NewCatInvocation(group ReleaseGroup, version string) (GroupInvocation, error)

func NewChangelogInvocation added in v0.0.7

func NewChangelogInvocation(group ReleaseGroup, nextVersion string, status *ReleaseGroupStatus) (GroupInvocation, error)

func NewCurrentInvocation added in v0.0.7

func NewCurrentInvocation(group ReleaseGroup) (GroupInvocation, error)

func NewNextInvocation added in v0.0.7

func NewNextInvocation(group ReleaseGroup, nextVersion string) (GroupInvocation, error)

type InvalidConfigError added in v0.0.5

type InvalidConfigError struct {
	// contains filtered or unexported fields
}

func (*InvalidConfigError) Error added in v0.0.5

func (e *InvalidConfigError) Error() string

type LogEntry added in v0.0.5

type LogEntry struct {
	Timestamp int64
	Commit    string
	Content   string
}

type ParsedBump added in v0.0.7

type ParsedBump struct {
	File    string
	Levels  map[string]string
	Message string
	Commit  *Commit
}

ParsedBump is one bump file's parsed content plus its provenance: the levels recorded per release group, the changelog message, and the commit that introduced the file (nil when unresolved).

func GatherBumps added in v0.0.7

func GatherBumps(ctx context.Context, logger *slog.Logger, dir string, provenance Provenance) ([]ParsedBump, error)

GatherBumps globs the pending bump files in dir, parses each file's front matter and message, and resolves the commit that introduced it.

type Provenance added in v0.0.7

type Provenance interface {
	Resolve(ctx context.Context, bumpFiles []string) (map[string]Commit, error)
}

Provenance resolves the commit that introduced each bump file. Files that cannot be resolved are absent from the returned map; callers treat that as "no provenance" rather than an error.

type ReleaseGroup

type ReleaseGroup struct {
	Name         string   `json:"name" toml:"name" yaml:"name"`
	DisplayName  string   `json:"display_name,omitempty" toml:"display_name,omitempty" yaml:"display_name,omitempty"`
	ChangelogCMD []string `json:"changelog_cmd,omitempty,omitzero" toml:"changelog_cmd,omitempty,omitzero" yaml:"changelog_cmd,omitempty,omitzero"`
	CatCMD       []string `json:"cat_cmd,omitempty,omitzero" toml:"cat_cmd,omitempty,omitzero" yaml:"cat_cmd,omitempty,omitzero"`
	CurrentCMD   []string `json:"current_cmd,omitempty,omitzero" toml:"current_cmd,omitempty,omitzero" yaml:"current_cmd,omitempty,omitzero"`
	NextCMD      []string `json:"next_cmd,omitempty,omitzero" toml:"next_cmd,omitempty,omitzero" yaml:"next_cmd,omitempty,omitzero"`
}

type ReleaseGroupStatus added in v0.0.5

type ReleaseGroupStatus struct {
	Level     BumpLevel
	MajorLogs []LogEntry
	MinorLogs []LogEntry
	PatchLogs []LogEntry
}

type Runner added in v0.0.7

type Runner interface {
	Run(ctx context.Context, dir string, inv GroupInvocation, stdout io.Writer) error
}

Runner executes resolved group commands. ExecRunner is the process-spawning implementation; FakeRunner substitutes in tests.

type Verb added in v0.0.7

type Verb string

Verb identifies one of the group-command hooks a release group configures in .bumper/config.toml.

const (
	VerbCurrent   Verb = "current"
	VerbNext      Verb = "next"
	VerbChangelog Verb = "changelog"
	VerbCat       Verb = "cat"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL