branch

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package branch provides branch name sanitization functionality.

Index

Constants

This section is empty.

Variables

View Source
var ErrBranchNameContainsAtBrace = &Error{message: "branch name cannot contain the sequence @{"}

ErrBranchNameContainsAtBrace is returned when the branch name contains the sequence @{.

View Source
var ErrBranchNameContainsBackslash = &Error{message: "branch name cannot contain backslash"}

ErrBranchNameContainsBackslash is returned when the branch name contains a backslash.

View Source
var ErrBranchNameEmpty = &Error{message: "branch name cannot be empty"}

ErrBranchNameEmpty is returned when the branch name is empty.

View Source
var ErrBranchNameEmptyAfterSanitization = &Error{message: "branch name becomes empty after sanitization"}

ErrBranchNameEmptyAfterSanitization is returned when the branch name becomes empty after sanitization.

View Source
var ErrBranchNameSingleAt = &Error{message: "branch name cannot be the single character @"}

ErrBranchNameSingleAt is returned when the branch name is just a single @ character.

Functions

func SanitizeBranchName

func SanitizeBranchName(branchName string) (string, error)

SanitizeBranchName sanitizes a branch name according to Git's branch naming rules. Git imposes the following rules on how references are named:

  • They can include slash / for hierarchical (directory) grouping, but no slash-separated component can begin with a dot . or end with the sequence .lock.
  • They cannot have two consecutive dots .. anywhere.
  • They cannot have ASCII control characters (i.e. bytes whose values are lower than \040, or \177 DEL), space, tilde ~, caret ^, or colon : anywhere.
  • They cannot have question-mark ?, asterisk *, or open bracket [ anywhere.
  • They cannot begin or end with a slash / or contain multiple consecutive slashes.
  • They cannot end with a dot .
  • They cannot contain a sequence @{.
  • They cannot be the single character @.
  • They cannot contain a \.
  • Additional rule for branch names: They cannot start with a dash -.

func SanitizeBranchNameForFilename added in v0.26.0

func SanitizeBranchNameForFilename(branchName string) string

SanitizeBranchNameForFilename sanitizes a branch name for use in filenames. This replaces filesystem-unsafe characters (like /) with safe alternatives.

Types

type Error

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

Error represents an error related to branch operations.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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