changeset

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package changeset provides core types and operations for managing changesets.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoChangesets     = errors.New("no changesets found")
	ErrNoManifest       = errors.New("release manifest not found")
	ErrInvalidChangeset = errors.New("invalid changeset format")
	ErrInvalidVersion   = errors.New("invalid semantic version")
	ErrUncommitted      = errors.New("uncommitted changes exist")
)

Sentinel errors for changeset operations.

Functions

func ChangesetDirExists

func ChangesetDirExists(dir string) bool

ChangesetDirExists returns true if the .changeset directory exists.

func DeleteChangeset

func DeleteChangeset(cs *Changeset) error

DeleteChangeset removes a changeset file.

func DeleteManifest

func DeleteManifest(dir string) error

DeleteManifest removes .changeset/release-manifest.json.

func GenerateID

func GenerateID() string

GenerateID returns a random changeset ID (e.g., "hungry-tiger-jump").

func IncrementVersion

func IncrementVersion(current string, bump Bump) (string, error)

IncrementVersion bumps a semantic version by the given bump type.

func InitChangeset

func InitChangeset(dir string, cfg *Config) error

InitChangeset creates the .changeset directory with config and README.

func ManifestExists

func ManifestExists(dir string) bool

ManifestExists returns true if release-manifest.json exists.

func WriteChangeset

func WriteChangeset(dir string, cs *Changeset) error

WriteChangeset writes a changeset to the .changeset directory. Generates a random ID if cs.ID is empty.

func WriteConfig

func WriteConfig(dir string, cfg *Config) error

WriteConfig writes config to .changeset/config.json.

func WriteManifest

func WriteManifest(dir string, m *Manifest) error

WriteManifest writes the manifest to .changeset/release-manifest.json.

Types

type Bump

type Bump string

Bump represents a semantic version bump type.

const (
	BumpPatch Bump = "patch"
	BumpMinor Bump = "minor"
	BumpMajor Bump = "major"
)

func (Bump) Compare

func (a Bump) Compare(b Bump) int

Compare returns:

-1 if a < b
 0 if a == b
 1 if a > b

Ordering: patch < minor < major

func (Bump) String

func (a Bump) String() string

String returns the string representation of the bump.

type Changeset

type Changeset struct {
	ID       string          // Filename without extension (e.g., "hungry-tiger-jump")
	Modules  map[string]Bump // Module short name -> bump type
	Summary  string          // Markdown description
	FilePath string          // Full path to the file
}

Changeset represents a single changeset file.

func ParseChangeset

func ParseChangeset(path string) (*Changeset, error)

ParseChangeset reads and parses a single changeset file. Returns error if file format is invalid.

func ReadChangesets

func ReadChangesets(dir string) ([]*Changeset, error)

ReadChangesets reads all changeset files from the .changeset directory. Skips config.json, README.md, and release-manifest.json.

type Config

type Config struct {
	Root          string   `json:"root"`          // Root module path
	BaseBranch    string   `json:"baseBranch"`    // Default: "main"
	Ignore        []string `json:"ignore"`        // Modules to ignore
	IgnorePaths   []string `json:"ignorePaths"`   // File paths to ignore in CI check
	DependentBump Bump     `json:"dependentBump"` // How to bump dependents (default: "patch")
}

Config represents .changeset/config.json.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with sensible defaults.

func ReadConfig

func ReadConfig(dir string) (*Config, error)

ReadConfig reads .changeset/config.json. Returns DefaultConfig if file doesn't exist.

type Manifest

type Manifest struct {
	Releases []Release `json:"releases"`
}

Manifest represents .changeset/release-manifest.json.

func ReadManifest

func ReadManifest(dir string) (*Manifest, error)

ReadManifest reads .changeset/release-manifest.json. Returns error if file doesn't exist.

type Release

type Release struct {
	Module          string `json:"module"`
	Version         string `json:"version"`
	PreviousVersion string `json:"previousVersion"`
	Bump            Bump   `json:"bump"`
	Reason          string `json:"reason,omitempty"` // "dependency" if auto-bumped
}

Release represents a computed release for a module.

func ComputeReleases

func ComputeReleases(
	changesets []*Changeset,
	graph *module.Graph,
	tags map[string]string,
	cfg *Config,
) ([]Release, error)

ComputeReleases calculates version bumps from changesets.

Algorithm:

  1. Aggregate bumps per module (highest bump wins)
  2. Get current versions from git tags
  3. Cascade bumps to dependent modules
  4. Compute next versions

Parameters:

  • changesets: All pending changesets
  • graph: Module dependency graph
  • tags: Current git tags (module short name -> version)
  • cfg: Config for dependent bump behavior

Returns releases sorted by module name.

func FilterIgnored

func FilterIgnored(releases []Release, ignore []string) []Release

FilterIgnored removes ignored modules from the releases list.

Jump to

Keyboard shortcuts

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