handler

package
v1.0.198 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package handler provides the internal functionalities of the semantic-pull-requests webhook

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGettingUserConfig is returned when getting the user config fails.
	ErrGettingUserConfig = errors.New("error getting user config")
	// ErrParsingUserConfig is returned when parsing the user config fails.
	ErrParsingUserConfig = errors.New("error parsing user config")
)

Functions

func Contains

func Contains(l []string, s string) bool

Contains checks if a slice has a given string case-insensitively.

func NewSemanticMachine added in v1.0.18

func NewSemanticMachine(conventionalTypes bool) *conventionalcommits.Machine

NewSemanticMachine instantiates and returns a new conventionalcommits parser machine.

Types

type SemanticPullRequests

type SemanticPullRequests struct {
	Client *bitbucket.Client
	Hook   *webhook.Webhook
	Logger *zap.Logger
}

SemanticPullRequests validates Bitbucket pull-requests.

func NewSemanticPullRequests

func NewSemanticPullRequests(
	username, password string,
	logger *zap.Logger,
) (*SemanticPullRequests, error)

NewSemanticPullRequests returns an initialized SemanticPullRequests.

func (*SemanticPullRequests) AreSemanticCommits added in v1.0.7

func (spr *SemanticPullRequests) AreSemanticCommits(
	machine *conventionalcommits.Machine,
	cfg *UserConfig,
	commits []interface{},
) bool

AreSemanticCommits validates a given list of Bitbucket commits.

func (*SemanticPullRequests) HandlePullRequestUpdate added in v1.0.113

func (spr *SemanticPullRequests) HandlePullRequestUpdate(w http.ResponseWriter, r *http.Request)

HandlePullRequestUpdate handles pull-request update events.

func (*SemanticPullRequests) IsSemanticMessage

func (spr *SemanticPullRequests) IsSemanticMessage(
	machine *conventionalcommits.Machine,
	cfg *UserConfig,
	msg string,
) bool

IsSemanticMessage validates the semantic of a given message.

type UserConfig

type UserConfig struct {
	Enabled            *bool     `yaml:"enabled"`
	TitleOnly          *bool     `yaml:"titleOnly"`
	CommitsOnly        *bool     `yaml:"commitsOnly"`
	TitleAndCommits    *bool     `yaml:"titleAndCommits"`
	AnyCommit          *bool     `yaml:"anyCommit"`
	Scopes             *[]string `yaml:"scopes"`
	Types              *[]string `yaml:"types"`
	AllowMergeCommits  *bool     `yaml:"allowMergeCommits"`
	AllowRevertCommits *bool     `yaml:"allowRevertCommits"`
}

UserConfig represents a repository-level configuration for SemanticPullRequests.

func DefaultUserConfig

func DefaultUserConfig() *UserConfig

DefaultUserConfig returns an initialised UserConfig with default values.

func GetUserConfig

func GetUserConfig(client *bitbucket.Client, owner, repoSlug string) (*UserConfig, error)

GetUserConfig returns the user config for a given repository.

Jump to

Keyboard shortcuts

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