models

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BumpType

type BumpType string

BumpType represents the type of version bump

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

func ParseBumpType

func ParseBumpType(s string) (BumpType, error)

ParseBumpType parses a string into a BumpType

func (BumpType) IsValid

func (b BumpType) IsValid() bool

IsValid checks if the bump type is valid

func (BumpType) String

func (b BumpType) String() string

String returns the string representation of BumpType

type Changeset

type Changeset struct {
	// ID is the unique identifier for this changeset (filename without extension)
	ID string

	// Projects maps project names to their bump types
	Projects map[string]BumpType

	// Message is the markdown content describing the change
	Message string

	// FilePath is the path to the changeset file
	FilePath string

	// PR contains optional pull request metadata (populated via GitHub API)
	PR *PullRequest
}

Changeset represents a changeset file with its metadata

func NewChangeset

func NewChangeset(id string, projects map[string]BumpType, message string) *Changeset

NewChangeset creates a new Changeset instance

func (*Changeset) AffectsProject

func (c *Changeset) AffectsProject(projectName string) bool

AffectsProject checks if this changeset affects a specific project

func (*Changeset) FormatPRSuffix

func (c *Changeset) FormatPRSuffix(includeLink bool) string

FormatPRSuffix returns a formatted PR reference string for use in changelogs Returns empty string if no PR is associated Format: "(#123 by @author)" or "[#123](url) by @author" if includeLink is true

func (*Changeset) GetBumpForProject

func (c *Changeset) GetBumpForProject(projectName string) (BumpType, bool)

GetBumpForProject returns the bump type for a specific project

type ChangesetSummary

type ChangesetSummary struct {
	// ID is the changeset identifier (filename without extension)
	ID string `json:"id"`

	// BumpType is the semantic version bump type for this project
	BumpType BumpType `json:"bumpType"`

	// Message is the changeset description
	Message string `json:"message"`
}

ChangesetSummary is a simplified changeset representation for context

type FilterType

type FilterType string

FilterType represents a filter for selecting projects

const (
	// FilterAll selects all projects
	FilterAll FilterType = "all"

	// FilterOpenChangesets selects projects with changesets in .changeset/
	FilterOpenChangesets FilterType = "open-changesets"

	// FilterOutdatedVersions selects projects where version.txt > latest git tag
	FilterOutdatedVersions FilterType = "outdated-versions"

	// FilterHasVersion selects projects with a version.txt file
	FilterHasVersion FilterType = "has-version"

	// FilterNoVersion selects projects without a version.txt file
	FilterNoVersion FilterType = "no-version"

	// FilterUnchanged selects projects with no changesets
	FilterUnchanged FilterType = "unchanged"
)

func ParseFilterType

func ParseFilterType(s string) (FilterType, error)

ParseFilterType parses a string into a FilterType

func (FilterType) IsValid

func (f FilterType) IsValid() bool

IsValid checks if the filter type is valid

func (FilterType) MatchesContext

func (f FilterType) MatchesContext(ctx *ProjectContext) bool

MatchesContext checks if a ProjectContext matches this filter

func (FilterType) String

func (f FilterType) String() string

String returns the string representation of FilterType

type Project

type Project struct {
	// Name is the project identifier (unique within the workspace)
	Name string

	// RootPath is the absolute path to the project root
	RootPath string

	// ModulePath is the full module path from go.mod (Go projects only)
	ModulePath string

	// ManifestPath is the path to the manifest (go.mod).
	ManifestPath string

	// Type indicates the project type.
	Type ProjectType
}

Project represents a project/module in the workspace.

func NewProject

func NewProject(name, rootPath, modulePath, manifestPath string, projectType ProjectType) *Project

NewProject creates a new Project instance

type ProjectContext

type ProjectContext struct {
	// Project is the project name
	Project string `json:"project"`

	// ProjectPath is the absolute path to the project root
	ProjectPath string `json:"projectPath"`

	// ModulePath is the full module path from go.mod
	ModulePath string `json:"modulePath"`

	// Changesets contains summaries of all changesets affecting this project
	Changesets []ChangesetSummary `json:"changesets"`

	// CurrentVersion is the parsed project version (defaults to "0.0.0")
	CurrentVersion string `json:"currentVersion"`

	// HasVersionFile indicates whether `version.txt` exists for this project.
	HasVersionFile bool `json:"hasVersionFile"`

	// LatestTag is the latest git tag for this project (or "0.0.0" if none)
	LatestTag string `json:"latestTag"`

	// HasChangesets indicates if there are any changesets for this project
	HasChangesets bool `json:"hasChangesets"`

	// IsOutdated indicates if CurrentVersion > LatestTag
	IsOutdated bool `json:"isOutdated"`

	// ChangelogPreview contains the markdown that will be added to CHANGELOG.md
	// Empty string if no changesets
	ChangelogPreview string `json:"changelogPreview"`
}

ProjectContext represents the context passed to commands via STDIN when executed through 'changeset each'

type ProjectType

type ProjectType string

ProjectType represents the kind of project.

Today go-changeset supports Go workspaces only.

const (
	ProjectTypeGo ProjectType = "go"
)

type PullRequest

type PullRequest struct {
	// Number is the PR number (e.g., 123)
	Number int

	// Title is the PR title
	Title string

	// URL is the full URL to the PR (e.g., https://github.com/owner/repo/pull/123)
	URL string

	// Author is the GitHub username of the PR author
	Author string

	// Labels are the labels assigned to the PR
	Labels []string
}

PullRequest represents GitHub pull request metadata

type Version

type Version struct {
	Major      int
	Minor      int
	Patch      int
	Prerelease string // e.g., "rc0", "rc1", etc.
}

Version represents a semantic version

func ParseVersion

func ParseVersion(s string) (*Version, error)

ParseVersion parses a version string (e.g., "1.2.3", "v1.2.3", "1.2.3-rc0")

func (*Version) Bump

func (v *Version) Bump(bumpType BumpType) *Version

Bump creates a new version by applying a bump type

func (*Version) Compare

func (v *Version) Compare(other *Version) int

Compare compares two versions Returns -1 if v < other, 0 if v == other, 1 if v > other Prerelease versions are ordered before release versions (e.g., 1.2.3-rc0 < 1.2.3)

func (*Version) IsPrerelease

func (v *Version) IsPrerelease() bool

IsPrerelease returns true if this version has a prerelease suffix

func (*Version) String

func (v *Version) String() string

String returns the version as a string without 'v' prefix

func (*Version) StripPrerelease

func (v *Version) StripPrerelease() *Version

StripPrerelease returns a new version without the prerelease suffix

func (*Version) Tag

func (v *Version) Tag() string

Tag returns the version as a tag string with 'v' prefix

func (*Version) WithPrerelease

func (v *Version) WithPrerelease(prerelease string) *Version

WithPrerelease returns a new version with the specified prerelease suffix

Jump to

Keyboard shortcuts

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