scm

package
v0.14.7 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 10 Imported by: 0

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 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 Actor added in v0.10.1

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

type Client

type Client interface {
	ApplyStep(ctx context.Context, evalContext EvalContext, update *UpdateMergeRequestOptions, step EvaluationActionStep) error
	EvalContext(ctx context.Context) (EvalContext, error)
	FindMergeRequestsForPeriodicEvaluation(ctx context.Context, filters MergeRequestListFilters) ([]PeriodicEvaluationMergeRequest, error)
	Labels() LabelClient
	MergeRequests() MergeRequestClient
	Start(ctx context.Context) error
	Stop(ctx context.Context, err error) 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 {
	CanUseConfigurationFileFromChangeRequest(ctx context.Context) bool
	GetDescription() string
	IsValid() bool
	SetContext(ctx context.Context)
	SetWebhookEvent(in any)
	TrackActionGroupExecution(name string)
	HasExecutedActionGroup(name string) bool
}

type EvalContextualizer

type EvalContextualizer struct{}

type EvaluationActionResult added in v0.3.0

type EvaluationActionResult struct {
	Name  string                 `yaml:"name"`
	Group string                 `yaml:"group"`
	If    string                 `yaml:"if"`
	Then  []EvaluationActionStep `yaml:"then"`
}

type EvaluationActionStep added in v0.3.0

type EvaluationActionStep map[string]any

func (EvaluationActionStep) OptionalString added in v0.14.0

func (step EvaluationActionStep) OptionalString(name, defaultValue string) (string, error)

func (EvaluationActionStep) RequiredString added in v0.14.0

func (step EvaluationActionStep) RequiredString(name string) (string, error)

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
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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