branch

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MaxSlugLen = 50

MaxSlugLen caps the slugged title length. Combined with a typical issue ID and type, this keeps the full branch name comfortably under ~100 chars even when an operator adds --variant.

Variables

This section is empty.

Functions

func CutReviewSuffix added in v0.13.1

func CutReviewSuffix(name string) (string, bool)

CutReviewSuffix returns the issue slug for a review branch name, and whether name was a review branch.

func IsReviewBranch added in v0.13.1

func IsReviewBranch(name string) bool

IsReviewBranch reports whether name is a review branch ("<slug>@review").

func ReviewBranchName added in v0.13.1

func ReviewBranchName(issueSlug string) string

ReviewBranchName returns the review branch name for an issue slug: "<issueSlug>@review".

func Slug

func Slug(title string) string

Slug normalises a free-form title for use as a branch-name segment. The result is lowercased, alphanumeric + single hyphens only, trimmed, and capped at MaxSlugLen with any trailing hyphen stripped.

Types

type Branch

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

Branch is the parsed shape of a git-zf branch name.

3-part name: <issueID>@<type>@<slug>             — default
4-part name: <issueID>@<type>@<slug>@<variant>   — opt-in via --variant

Legacy branches with an 8-hex random suffix parse as 4-part with the suffix exposed verbatim via Variant(). The system no longer distinguishes legacy hex from operator-supplied labels.

func New

func New(issueID, branchType, title, variant string) (*Branch, error)

New constructs a Branch.

variant == ""  → 3-part name
variant != ""  → 4-part name; the variant is slugged and rejected
                 if the result is empty.

func Parse

func Parse(name string) (*Branch, error)

Parse accepts 3- or 4-part branch names. For 3-part names, Variant() returns "".

func (Branch) IssueID

func (b Branch) IssueID() string

func (Branch) Name

func (b Branch) Name() string

func (Branch) Title

func (b Branch) Title() string

func (Branch) Type

func (b Branch) Type() string

func (Branch) Variant added in v0.9.5

func (b Branch) Variant() string

Variant returns the trailing segment of a 4-part name, or "" for a 3-part name. The returned value may be an operator-supplied label or a legacy random-hex suffix; the API treats both the same way.

Jump to

Keyboard shortcuts

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