labeler

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	CanEvaluate func(target *Target) bool
	Evaluate    func(target *Target, matcher LabelMatcher) (bool, error)
	GetName     func() string
}

func AgeCondition added in v1.8.0

func AgeCondition(l *Labeler) Condition

func AuthorCanMergeCondition

func AuthorCanMergeCondition() Condition

func AuthorCondition

func AuthorCondition() Condition

func AuthorInTeamCondition added in v1.11.0

func AuthorInTeamCondition(l *Labeler) Condition

func BaseBranchCondition

func BaseBranchCondition() Condition

func BodyCondition

func BodyCondition() Condition

func BranchCondition

func BranchCondition() Condition

func FilesCondition

func FilesCondition(l *Labeler) Condition

func IsDraftCondition

func IsDraftCondition() Condition

func IsMergeableCondition

func IsMergeableCondition() Condition

func LastModifiedCondition added in v1.11.0

func LastModifiedCondition(l *Labeler) Condition

func SizeCondition

func SizeCondition(l *Labeler) Condition

func TitleCondition

func TitleCondition() Condition

func TypeCondition added in v1.9.0

func TypeCondition() Condition

type DefaultHttpClient

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

func (*DefaultHttpClient) Do

func (d *DefaultHttpClient) Do(req *http.Request) (*http.Response, error)

type DurationConfig added in v1.11.0

type DurationConfig struct {
	AtLeast string `yaml:"at-least"`
	AtMost  string `yaml:"at-most"`
}

type GitHubFacade added in v1.5.0

type GitHubFacade struct {
	GetRawDiff         func(owner, repo string, prNumber int) (string, error)
	GetPR              func(owner, repo string, prNumber int) (*gh.PullRequest, error)
	ListIssuesByRepo   func(owner, repo string) ([]*gh.Issue, error)
	ListPRs            func(owner, repo string) ([]*gh.PullRequest, error)
	IsUserMemberOfTeam func(org, user, team string) (bool, error)
}

Just to make this mockable..

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

func NewDefaultHttpClient

func NewDefaultHttpClient() HttpClient

type LabelMatcher

type LabelMatcher struct {
	Age            string          `yaml:"age,omitempty"` // Deprecated age config.
	AgeRange       *DurationConfig `yaml:"age-range,omitempty"`
	AuthorCanMerge string          `yaml:"author-can-merge"`
	Authors        []string
	AuthorInTeam   string `yaml:"author-in-team"`
	BaseBranch     string `yaml:"base-branch"`
	Body           string
	Branch         string
	Draft          string
	Files          []string
	Label          string
	LastModified   *DurationConfig `yaml:"last-modified"`
	Mergeable      string
	Negate         bool
	Size           *SizeConfig
	// size-legacy
	// These two are unused in the codebase (they get copied inside
	// the Size object), but we keep them to respect backwards
	// compatiblity parsing older configs without adding more
	// complexity.
	SizeAbove string `yaml:"size-above"`
	SizeBelow string `yaml:"size-below"`
	// size-legacy
	Title string
	Type  string
}

type LabelUpdates

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

LabelUpdates Represents a request to update the set of labels

type Labeler

type Labeler struct {
	FetchRepoConfig  func() (*LabelerConfigV1, error)
	ReplaceLabels    func(target *Target, labels []string) error
	GetCurrentLabels func(target *Target) ([]string, error)
	GitHubFacade     *GitHubFacade
	Client           HttpClient
}

func (*Labeler) ExecuteOn

func (l *Labeler) ExecuteOn(target *Target) error

func (*Labeler) HandleEvent

func (l *Labeler) HandleEvent(
	eventName string,
	payload *[]byte) error

HandleEvent takes a GitHub Event and its raw payload (see link below) to trigger an update to the issue / PR's labels.

https://developer.github.com/v3/activity/events/types/

func (*Labeler) ProcessAllIssues

func (l *Labeler) ProcessAllIssues(owner, repo string)

func (*Labeler) ProcessAllPRs

func (l *Labeler) ProcessAllPRs(owner, repo string)

type LabelerConfigV0

type LabelerConfigV0 map[string]LabelMatcher

type LabelerConfigV1

type LabelerConfigV1 struct {
	Version int32
	// When set to true, scheduled executions will process both PRs and
	// issues. Else, we will only process PRs. Defaults to "False"
	Issues bool
	// When set to true, we will only add labels when they match a rule
	// but it will NOT remove labels that were previously set and stop
	// matching a rule
	AppendOnly bool `yaml:"appendOnly"`
	Labels     []LabelMatcher
}

type SizeConfig added in v1.5.0

type SizeConfig struct {
	ExcludeFiles []string `yaml:"exclude-files"`
	Above        string
	Below        string
}

type Target

type Target struct {
	Author   string
	Body     string
	IssueNo  int
	Title    string
	Owner    string
	RepoName string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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