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

branchfilter

package
v0.99.8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package branchfilter matches branch names against comma-separated glob patterns (e.g. "main,release-*,feature/*").

Patterns follow filepath.Match semantics. Notably, `*` matches any run of non-separator characters and therefore never crosses `/`:

"release/*"  matches "release/v1"   but not "release/a/b"
"release-*"  matches "release-1.0"  but not "release/1.0"

There is no `**`; to match additional path levels, spell them out (e.g. "feature/*/*"). Malformed patterns (such as an unclosed "[") are rejected by New with an error wrapping filepath.ErrBadPattern — a bad pattern never silently matches nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchFilter

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

BranchFilter matches branch names against a set of comma-separated glob patterns. An empty filter matches all branches.

func New

func New(filterStr string) (*BranchFilter, error)

New creates a BranchFilter from a comma-separated list of glob patterns (e.g. "main,release-*,feature/*"). An empty string matches everything.

Each pattern is validated up front with filepath.Match; a malformed pattern yields an error wrapping filepath.ErrBadPattern instead of a filter that silently never matches.

func (*BranchFilter) FilterBranches

func (f *BranchFilter) FilterBranches(branches []string) []string

FilterBranches returns only the branches that match the filter.

func (*BranchFilter) IsEmpty

func (f *BranchFilter) IsEmpty() bool

IsEmpty reports whether the filter has no patterns (matches everything).

func (*BranchFilter) Match

func (f *BranchFilter) Match(branchName string) bool

Match reports whether branchName matches any of the filter's patterns. Returns true (matches everything) when the filter has no patterns.

func (*BranchFilter) Patterns

func (f *BranchFilter) Patterns() []string

Patterns returns the raw glob patterns that were used to create this filter.

Jump to

Keyboard shortcuts

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