Documentation
¶
Index ¶
- Constants
- Variables
- func ComputeNextVersion(lastTag, bumpType string) (string, error)
- func IsValid(version string) bool
- func IsValidDev(version string) bool
- func IsValidRC(version string) bool
- func IsValidStable(version string) bool
- func TopLevel(path string) (string, error)
- type Config
- type ExecutionFailedError
- type FileNotFoundError
- type FolderNotFoundError
- type InvalidConfigError
- type ReferenceNotFoundError
- type Repo
- func (r *Repo) EnsureUpToDate(ctx context.Context) error
- func (r *Repo) HeadBranch(ctx context.Context) (string, error)
- func (r *Repo) HeadSHA(ctx context.Context) (string, error)
- func (r *Repo) HeadTag(ctx context.Context) (string, error)
- func (r *Repo) NextVersion(ctx context.Context, bumpType string) (string, error)
- func (r *Repo) ReadFileAtRef(ctx context.Context, path, ref string) ([]byte, error)
- func (r *Repo) ReadFolderAtRef(ctx context.Context, path, ref string) ([]os.FileInfo, error)
- func (r *Repo) ResolveVersion(ctx context.Context, ref string) (string, error)
- type RepositoryNotFoundError
Constants ¶
const ( BumpTypePatch = "patch" BumpTypeMinor = "minor" BumpTypeMajor = "major" BumpTypePatchRC = "patch-rc" BumpTypeMinorRC = "minor-rc" BumpTypeMajorRC = "major-rc" BumpTypeRC = "rc" BumpTypeRCRelease = "rc-release" )
Bump type constants for use with ComputeNextVersion and NextVersion.
Variables ¶
var ValidBumpTypes = []string{ BumpTypePatch, BumpTypeMinor, BumpTypeMajor, BumpTypePatchRC, BumpTypeMinorRC, BumpTypeMajorRC, BumpTypeRC, BumpTypeRCRelease, }
ValidBumpTypes lists all accepted bump-type values in their canonical order.
Functions ¶
func ComputeNextVersion ¶ added in v1.1.0
ComputeNextVersion returns the next version after lastTag for the given bumpType. It is a pure function — no git access is required.
Valid from a stable tag (X.Y.Z): patch, minor, major, patch-rc, minor-rc, major-rc. Valid from an RC tag (X.Y.Z-rc.N): rc (bump counter), rc-release (finalize to stable).
The returned string never carries a leading "v".
Callers are responsible for stripping the GS_GIT_TAG_PREFIX and the separating "/" before passing lastTag to this function. For example, "module-a/v1.2.3" must be passed as "v1.2.3" (or "1.2.3").
func IsValid ¶
IsValid reports whether version is a valid version string in any of the three recognised formats: stable, RC, or dev build.
func IsValidDev ¶
IsValidDev reports whether version is a valid dev-build version (X.Y.Z-dev.<branch>.<YYYY-MM-DD>.<HH-MM-SS> or with a leading v, no leading zeros in X.Y.Z components).
func IsValidRC ¶
IsValidRC reports whether version is a valid release-candidate version (X.Y.Z-rc.N or vX.Y.Z-rc.N, no leading zeros in any numeric component).
func IsValidStable ¶
IsValidStable reports whether version is a valid stable release version (X.Y.Z or vX.Y.Z, no leading zeros in any component).
Types ¶
type ExecutionFailedError ¶
type ExecutionFailedError struct {
// contains filtered or unexported fields
}
func (*ExecutionFailedError) Error ¶
func (e *ExecutionFailedError) Error() string
func (*ExecutionFailedError) Is ¶
func (e *ExecutionFailedError) Is(target error) bool
type FileNotFoundError ¶
type FileNotFoundError struct {
// contains filtered or unexported fields
}
func (*FileNotFoundError) Error ¶
func (e *FileNotFoundError) Error() string
func (*FileNotFoundError) Is ¶
func (e *FileNotFoundError) Is(target error) bool
type FolderNotFoundError ¶
type FolderNotFoundError struct {
// contains filtered or unexported fields
}
func (*FolderNotFoundError) Error ¶
func (e *FolderNotFoundError) Error() string
func (*FolderNotFoundError) Is ¶
func (e *FolderNotFoundError) Is(target error) bool
type InvalidConfigError ¶
type InvalidConfigError struct {
// contains filtered or unexported fields
}
func (*InvalidConfigError) Error ¶
func (e *InvalidConfigError) Error() string
func (*InvalidConfigError) Is ¶
func (e *InvalidConfigError) Is(target error) bool
type ReferenceNotFoundError ¶
type ReferenceNotFoundError struct {
// contains filtered or unexported fields
}
func (*ReferenceNotFoundError) Error ¶
func (e *ReferenceNotFoundError) Error() string
func (*ReferenceNotFoundError) Is ¶
func (e *ReferenceNotFoundError) Is(target error) bool
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
func (*Repo) EnsureUpToDate ¶
EnsureUpToDate fetches latest changes from remote.
func (*Repo) HeadBranch ¶
HeadBranch returns branch name for the HEAD ref.
func (*Repo) HeadTag ¶
HeadTag returns tag for the HEAD ref.
If GS_GIT_TAG_PREFIX environment variable is set, it looks for tags prefixed with that. For example, when the value is 'module-a', it filters found tags to 'module-a/v1.2.0', must match <module_name>/v<semantic_version>.
Note: if GS_GIT_TAG_PREFIX is not set, all tags matching the prefixed tag regex are filtered out!
It returns a *ReferenceNotFoundError when the HEAD ref is not tagged, detectable via errors.Is(err, &ReferenceNotFoundError{}).
func (*Repo) NextVersion ¶ added in v1.1.0
NextVersion returns the next version tag after the highest-semver tag reachable from HEAD for the given bumpType.
Valid bump types from a stable tag: patch, minor, major, patch-rc, minor-rc, major-rc. Valid bump types from an RC tag: rc (bump counter), rc-release (finalize to stable).
When no version tags are reachable from HEAD, v0.0.0 is used as the implicit base, which means only the stable bump types (patch/minor/major/patch-rc/minor-rc/major-rc) are valid.
The returned string never carries a leading "v". If GS_GIT_TAG_PREFIX is set, only tags carrying that prefix are considered (monorepo support).
func (*Repo) ReadFileAtRef ¶ added in v1.1.0
ReadFileAtRef retrieves content of file stored at path on version specified in ref. When empty ref defaults to master branch. Note: internally this checks out the given ref, mutating the working tree.
func (*Repo) ReadFolderAtRef ¶ added in v1.1.0
ReadFolderAtRef retrieves content of a folder stored at path on version specified in ref. When empty ref defaults to master branch. Note: internally this checks out the given ref, mutating the working tree.
func (*Repo) ResolveVersion ¶
ResolveVersion resolves the version for a git reference:
- Stable tag vX.Y.Z on the commit → returns "X.Y.Z"
- Pre-release tag vX.Y.Z-<pre> on the commit → returns "X.Y.Z-<pre>" (e.g. "1.2.3-rc.1")
- Untagged commit → returns a semVer dev build: "X.Y.(Z+1)-dev.<branch>.<YYYY-MM-DD>.<HH-MM-SS>" where X.Y.Z is the most recent stable (non-pre-release) ancestor tag reachable from the reference, or "0.0.0" when no stable ancestor exists. The branch name is resolved from GS_BRANCH_NAME env var, then the HEAD branch of the CWD git repo, then "unknown". Non-reachable tags are never used as the base.
If GS_GIT_TAG_PREFIX is set, only tags prefixed with "<value>/" are considered, e.g. "module-a/v1.2.3". The prefix, separator, and "v" are stripped from the result.
It returns a *ReferenceNotFoundError when the reference cannot be resolved, detectable via errors.Is(err, &ReferenceNotFoundError{}).
type RepositoryNotFoundError ¶
type RepositoryNotFoundError struct {
// contains filtered or unexported fields
}
func (*RepositoryNotFoundError) Error ¶
func (e *RepositoryNotFoundError) Error() string
func (*RepositoryNotFoundError) Is ¶
func (e *RepositoryNotFoundError) Is(target error) bool