branch

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package branch provides types and functions for working with git branches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

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

Branch represents a git branch with its name.

It encapsulates the branch name and provides methods to interact with it.

func NewBranch

func NewBranch(name Name) Branch

NewBranch creates a new Branch instance with the given Name.

func (Branch) String

func (b Branch) String() string

String returns the string representation of the Branch, which is its Name.

type Name

type Name string

Name represents the name of a git branch.

func NewName

func NewName(name string) Name

NewName creates a new branch Name from the given string.

func (Name) Empty

func (n Name) Empty() bool

Empty checks if the branch name is empty.

func (Name) String

func (n Name) String() string

String returns the string representation of the branch name.

func (Name) Ticket added in v1.0.0

func (n Name) Ticket(re *regexp.Regexp) ticket.Ticket

Ticket extracts a Ticket from the branch name using the provided regular expression.

The regular expression should contain a capturing group that matches the ticket name. If the branch name is empty or does not match the regular expression, an empty Ticket is returned.

Example usage:

re := regexp.MustCompile(`^(?:feature|bugfix|hotfix)/([A-Z]+-\d+)`)
t := NewName("feature/TASK-1234").Ticket(re)
fmt.Println(t.Name()) // Output: TASK-1234

Jump to

Keyboard shortcuts

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