context

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package context provides the GitVersionContext, the immutable snapshot of git state and configuration used for version calculation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitVersionContext

type GitVersionContext struct {
	// CurrentBranch is the branch being versioned.
	CurrentBranch git.Branch

	// CurrentCommit is the commit being versioned (branch tip or explicit SHA).
	CurrentCommit git.Commit

	// FullConfiguration is the merged configuration (defaults + user overrides).
	FullConfiguration *config.Config

	// CurrentCommitTaggedVersion is the semantic version tag on the current
	// commit, if any. Zero value with IsCurrentCommitTagged=false means no tag.
	CurrentCommitTaggedVersion semver.SemanticVersion

	// IsCurrentCommitTagged is true when the current commit has a version tag.
	IsCurrentCommitTagged bool

	// NumberOfUncommittedChanges counts dirty working directory entries.
	NumberOfUncommittedChanges int
}

GitVersionContext holds the resolved state needed for version calculation. It is created once per invocation and passed to all strategies.

func NewContext

func NewContext(store *git.RepositoryStore, repo git.Repository, cfg *config.Config, opts Options) (*GitVersionContext, error)

NewContext creates a GitVersionContext by resolving the target branch, current commit, version tags, and uncommitted change count.

func (*GitVersionContext) GetEffectiveConfiguration

func (ctx *GitVersionContext) GetEffectiveConfiguration(branchName string) (config.EffectiveConfiguration, error)

GetEffectiveConfiguration resolves the effective configuration for the given branch, using the context's full configuration.

type Options

type Options struct {
	// TargetBranch overrides HEAD. Empty string means use HEAD.
	TargetBranch string

	// CommitID overrides the branch tip. Empty string means use tip.
	CommitID string
}

Options configures what the factory resolves.

Jump to

Keyboard shortcuts

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