scm

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 10 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

func FindModifiedFiles added in v0.8.0

func FindModifiedFiles(files []string, patterns ...string) []string

Partially lifted from https://github.com/hmarr/codeowners/blob/main/match.go

func MergeSlices added in v0.21.0

func MergeSlices[T any](aSlice []T, bSlice []T, uniqFunc func(T) string) []T

func Ptr added in v0.8.0

func Ptr[T any](v T) *T

Ptr is a helper that returns a pointer to v.

Types

type ActionStep added in v0.18.0

type ActionStep interface {
	RequiredInt(name string) (int, error)
	RequiredString(name string) (string, error)
	RequiredStringEnum(name string, values ...string) (string, error)
	RequiredStringSlice(name string) ([]string, error)
	OptionalInt(name string, fallback int) (int, error)
	OptionalString(name, fallback string) (string, error)
	OptionalStringEnum(name string, fallback string, values ...string) (string, error)
	Get(name string) (any, error)
}

type Actor added in v0.10.1

type Actor struct {
	ID       string
	Username string
	Email    *string
	IsBot    bool
}

func (Actor) IntID added in v0.21.0

func (a Actor) IntID() int

IntID is a safe parser for the ID field of an Actor, returning 0 if the ID cannot be parsed as an integer since Gitlab user IDs start at 1.

type Actors added in v0.21.0

type Actors []Actor

func (*Actors) Add added in v0.21.0

func (a *Actors) Add(actor Actor)

func (Actors) Has added in v0.21.0

func (a Actors) Has(actor Actor) bool

type Client

type Client interface {
	ApplyStep(ctx context.Context, evalContext EvalContext, update *UpdateMergeRequestOptions, step ActionStep) error
	EvalContext(ctx context.Context) (EvalContext, error)
	FindMergeRequestsForPeriodicEvaluation(ctx context.Context, filters MergeRequestListFilters) ([]PeriodicEvaluationMergeRequest, error)
	GetProjectFiles(ctx context.Context, project string, ref *string, files []string) (map[string]string, error)
	Labels() LabelClient
	MergeRequests() MergeRequestClient
	Start(ctx context.Context) error
	Stop(ctx context.Context, err error, allowPipelineFailure bool) error
}

type CreateLabelOptions

type CreateLabelOptions struct {
	Name        *string          `json:"name,omitempty"        url:"name,omitempty"`
	Color       *string          `json:"color,omitempty"       url:"color,omitempty"`
	Description *string          `json:"description,omitempty" url:"description,omitempty"`
	Priority    types.Value[int] `json:"priority"              url:"priority,omitempty"`
}

CreateLabelOptions represents the available CreateLabel() options.

GitLab API docs: https://docs.gitlab.com/ee/api/labels.html#create-a-new-label

type EvalContext

type EvalContext interface {
	AllowPipelineFailure(ctx context.Context) bool
	CanUseConfigurationFileFromChangeRequest(ctx context.Context) bool
	GetDescription() string
	HasExecutedActionGroup(name string) bool
	IsValid() bool
	SetContext(ctx context.Context)
	SetWebhookEvent(in any)
	TrackActionGroupExecution(name string)
	GetCodeOwners() Actors
	GetReviewers() Actors
	GetAuthor() Actor
	GetLabels() []string
}

type EvalContextualizer

type EvalContextualizer struct{}

type EvaluationResult

type EvaluationResult struct {
	// Name of the label being generated.
	//
	// May only be used with [conditional] labelling type
	Name string

	// Description for the label being generated.
	//
	// Optional; will be an empty string if omitted
	Description string

	// The HEX color code to use for the label.
	//
	// May use the color variables (e.g., $purple-300) defined in Twitter Bootstrap
	// https://getbootstrap.com/docs/5.3/customize/color/#all-colors
	Color string

	// Priority controls wether the label should be a priority label or regular one.
	//
	// This controls if the label is prioritized (sorted first) in the list.
	Priority types.Value[int]

	// Wether the evaluation rule matched positive (add label) or negative (remove label)
	Matched bool
}

func (EvaluationResult) IsEqual added in v0.3.0

func (local EvaluationResult) IsEqual(ctx context.Context, remote *Label) bool

type Label

type Label struct {
	ID                     int              `json:"id"`
	Name                   string           `json:"name"`
	Color                  string           `json:"color"`
	TextColor              string           `json:"text_color"`
	Description            string           `json:"description"`
	OpenIssuesCount        int              `json:"open_issues_count"`
	ClosedIssuesCount      int              `json:"closed_issues_count"`
	OpenMergeRequestsCount int              `json:"open_merge_requests_count"`
	Subscribed             bool             `json:"subscribed"`
	Priority               types.Value[int] `json:"priority"`
	IsProjectLabel         bool             `json:"is_project_label"`
}

Label represents a GitLab label.

GitLab API docs: https://docs.gitlab.com/ee/api/labels.html

type LabelClient

type LabelClient interface {
	Create(ctx context.Context, opt *CreateLabelOptions) (*Label, *Response, error)
	List(ctx context.Context) ([]*Label, error)
	Update(ctx context.Context, opt *UpdateLabelOptions) (*Label, *Response, error)
}

type LabelOptions

type LabelOptions []string

LabelOptions is a custom type with specific marshaling characteristics.

type ListLabelsOptions

type ListLabelsOptions struct {
	ListOptions

	WithCounts            *bool   `json:"with_counts,omitempty"             url:"with_counts,omitempty"`
	IncludeAncestorGroups *bool   `json:"include_ancestor_groups,omitempty" url:"include_ancestor_groups,omitempty"`
	Search                *string `json:"search,omitempty"                  url:"search,omitempty"`
}

ListLabelsOptions represents the available ListLabels() options.

GitLab API docs: https://docs.gitlab.com/ee/api/labels.html#list-labels

type ListMergeRequest added in v0.3.0

type ListMergeRequest struct {
	ID  string `expr:"id"  graphql:"id"`
	SHA string `expr:"sha" graphql:"sha"`
}

type ListMergeRequestsOptions added in v0.3.0

type ListMergeRequestsOptions struct {
	ListOptions
	State string
	First int
}

type ListOptions

type ListOptions struct {
	// For offset-based paginated result sets, page of results to retrieve.
	Page int `json:"page,omitempty" url:"page,omitempty"`
	// For offset-based and keyset-based paginated result sets, the number of results to include per page.
	PerPage int `json:"per_page,omitempty" url:"per_page,omitempty"`

	// For keyset-based paginated result sets, name of the column by which to order
	OrderBy string `json:"order_by,omitempty" url:"order_by,omitempty"`
	// For keyset-based paginated result sets, the value must be `"keyset"`
	Pagination string `json:"pagination,omitempty" url:"pagination,omitempty"`
	// For keyset-based paginated result sets, sort order (`"asc"“ or `"desc"`)
	Sort string `json:"sort,omitempty" url:"sort,omitempty"`
}

ListOptions specifies the optional parameters to various List methods that support pagination.

type MergeRequestClient

type MergeRequestClient interface {
	GetRemoteConfig(ctx context.Context, name string, ref string) (io.Reader, error)
	List(ctx context.Context, options *ListMergeRequestsOptions) ([]ListMergeRequest, error)
	Update(ctx context.Context, opt *UpdateMergeRequestOptions) (*Response, error)
}

type MergeRequestListFilters added in v0.12.0

type MergeRequestListFilters struct {
	IgnoreMergeRequestWithLabels []string
	OnlyProjectsWithMembership   bool
	OnlyProjectsWithTopics       []string
	OnlyMergeRequestsWithLabels  []string
	SCMConfigurationFilePath     string
}

func (*MergeRequestListFilters) AsGraphqlVariables added in v0.12.0

func (filter *MergeRequestListFilters) AsGraphqlVariables() map[string]any

type PeriodicEvaluationMergeRequest added in v0.12.0

type PeriodicEvaluationMergeRequest struct {
	Project        string
	MergeRequestID string
	SHA            string
	ConfigBlob     string
	UpdatePipeline bool
}

type Response

type Response struct {
	*http.Response

	// Fields used for offset-based pagination.
	// TotalItems   int
	// TotalPages   int
	// ItemsPerPage int
	// CurrentPage  int
	NextPage int
}

Response is a GitLab API response. This wraps the standard http.Response returned from GitLab and provides convenient access to things like pagination links.

type UpdateLabelOptions

type UpdateLabelOptions struct {
	Name        *string          `json:"name,omitempty"        url:"name,omitempty"`
	NewName     *string          `json:"new_name,omitempty"    url:"new_name,omitempty"`
	Color       *string          `json:"color,omitempty"       url:"color,omitempty"`
	Description *string          `json:"description,omitempty" url:"description,omitempty"`
	Priority    types.Value[int] `json:"priority"              url:"priority,omitempty"`
}

type UpdateMergeRequestOptions

type UpdateMergeRequestOptions struct {
	Title              *string       `json:"title,omitempty"                url:"title,omitempty"`
	Description        *string       `json:"description,omitempty"          url:"description,omitempty"`
	TargetBranch       *string       `json:"target_branch,omitempty"        url:"target_branch,omitempty"`
	AssigneeID         *int          `json:"assignee_id,omitempty"          url:"assignee_id,omitempty"`
	AssigneeIDs        *[]int        `json:"assignee_ids,omitempty"         url:"assignee_ids,omitempty"`
	ReviewerIDs        *[]int        `json:"reviewer_ids,omitempty"         url:"reviewer_ids,omitempty"`
	Labels             *LabelOptions `json:"labels,omitempty"               url:"labels,comma,omitempty"`
	AddLabels          *LabelOptions `json:"add_labels,omitempty"           url:"add_labels,comma,omitempty"`
	RemoveLabels       *LabelOptions `json:"remove_labels,omitempty"        url:"remove_labels,comma,omitempty"`
	MilestoneID        *int          `json:"milestone_id,omitempty"         url:"milestone_id,omitempty"`
	StateEvent         *string       `json:"state_event,omitempty"          url:"state_event,omitempty"`
	RemoveSourceBranch *bool         `json:"remove_source_branch,omitempty" url:"remove_source_branch,omitempty"`
	Squash             *bool         `json:"squash,omitempty"               url:"squash,omitempty"`
	DiscussionLocked   *bool         `json:"discussion_locked,omitempty"    url:"discussion_locked,omitempty"`
	AllowCollaboration *bool         `json:"allow_collaboration,omitempty"  url:"allow_collaboration,omitempty"`
}

UpdateMergeRequestOptions represents the available UpdateMergeRequest() options.

GitLab API docs: https://docs.gitlab.com/ee/api/merge_requests.html#update-mr

func (*UpdateMergeRequestOptions) AppendReviewerIDs added in v0.21.0

func (o *UpdateMergeRequestOptions) AppendReviewerIDs(reviewerIDs []int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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