Help us shape the future of Go! Take the 2026 Go Developer Survey

branchname

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package branchname sanitizes, validates, and generates Git branch names.

Index

Constants

View Source
const (
	// MaxByteLength is the maximum length for a branch name.
	// Git refs have a max length of 256 bytes, minus 22 for "refs/stackit/metadata/"
	MaxByteLength = 234
)

Variables

This section is empty.

Functions

func FromMessage

func FromMessage(message string) string

FromMessage generates a branch name from a commit message subject.

func Sanitize

func Sanitize(name string) string

Sanitize turns arbitrary text into a valid branch name by replacing invalid characters

func Validate

func Validate(name string) error

Validate checks if a branch name is valid according to Git rules. Returns an error describing the issue if invalid, nil if valid.

Types

type InvalidError

type InvalidError struct {
	Name   string
	Reason string
}

InvalidError reports why a branch name is invalid.

func (*InvalidError) Error

func (e *InvalidError) Error() string

Jump to

Keyboard shortcuts

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