scm

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package scm is a generated GoMock package.

Index

Constants

View Source
const (
	EventComment = "COMMENT"
	EventPing    = "PING"
)

Variables

This section is empty.

Functions

func DetectProvider

func DetectProvider(uri string) (model.SCMProvider, error)

DetectProvider tenta detectar o provider SCM baseado na URI Suporta Azure DevOps, GitHub e GitLab na nuvem Para instalações self-hosted, o provider deve ser informado explicitamente

Types

type Client

type Client interface {
	GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

	BranchStatus(ctx context.Context, owner, repo string, sourceBranch, targetBranch string) (*GitBranchStats, error)

	// Comment creates a new PR thread. Always posts a new comment, no deduplication.
	Comment(ctx context.Context, owner, repo string, number int, body string) error

	// CommentUpdate upserts a PR comment identified by key.
	// If a previous comment with the same key exists it is updated; otherwise a new one is created.
	CommentUpdate(ctx context.Context, owner, repo string, number int, key, body string) error

	// CommentClose resolves/closes a PR comment identified by key.
	// Azure: marks the thread as Closed. GitHub: updates the comment body to show it was applied.
	CommentClose(ctx context.Context, owner, repo string, number int, key string) error

	SetStatus(ctx context.Context, owner, repo, sha string, state string, description string, targetURL string) error

	// MergePR completa (merge) o pull request especificado
	MergePR(ctx context.Context, owner, repo string, number int, headSHA string) error

	// FetchRepositoryMetadata busca metadados completos do repositório via API do provider
	// Aceita URI ou ID nativo como identificador
	// Retorna RepositoryMetadata completo com ID nativo, nome, URI e metadados específicos do provider
	FetchRepositoryMetadata(ctx context.Context, identifier string) (*model.RepositoryMetadata, error)
}

type GitBranchStats

type GitBranchStats struct {
	Name        string
	AheadCount  int
	BehindCount int
}

type MergeError

type MergeError struct {
	Err       error
	Code      int // HTTP status code; 0 for network/transport errors
	Retryable bool
}

MergeError wraps an SCM merge failure with an HTTP status code and a retryability flag.

Retryable=true → transient: network errors (Code 0), 400 (policy/conflict), 5xx Retryable=false → permanent: 401 (invalid PAT), 403 (no permission), 404 (not found)

func NewMergeError

func NewMergeError(err error, code int) *MergeError

NewMergeError builds a MergeError from a raw error and its HTTP status code.

func (*MergeError) Error

func (e *MergeError) Error() string

func (*MergeError) Unwrap

func (e *MergeError) Unwrap() error

type MockClient

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

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) BranchStatus

func (m *MockClient) BranchStatus(ctx context.Context, owner, repo, sourceBranch, targetBranch string) (*GitBranchStats, error)

BranchStatus mocks base method.

func (*MockClient) Comment

func (m *MockClient) Comment(ctx context.Context, owner, repo string, number int, body string) error

Comment mocks base method.

func (*MockClient) CommentClose

func (m *MockClient) CommentClose(ctx context.Context, owner, repo string, number int, key string) error

CommentClose mocks base method.

func (*MockClient) CommentUpdate

func (m *MockClient) CommentUpdate(ctx context.Context, owner, repo string, number int, key, body string) error

CommentUpdate mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) FetchRepositoryMetadata

func (m *MockClient) FetchRepositoryMetadata(ctx context.Context, identifier string) (*model.RepositoryMetadata, error)

FetchRepositoryMetadata mocks base method.

func (*MockClient) GetPullRequest

func (m *MockClient) GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

GetPullRequest mocks base method.

func (*MockClient) MergePR

func (m *MockClient) MergePR(ctx context.Context, owner, repo string, number int, headSHA string) error

MergePR mocks base method.

func (*MockClient) SetStatus

func (m *MockClient) SetStatus(ctx context.Context, owner, repo, sha, state, description, targetURL string) error

SetStatus mocks base method.

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) BranchStatus

func (mr *MockClientMockRecorder) BranchStatus(ctx, owner, repo, sourceBranch, targetBranch any) *gomock.Call

BranchStatus indicates an expected call of BranchStatus.

func (*MockClientMockRecorder) Comment

func (mr *MockClientMockRecorder) Comment(ctx, owner, repo, number, body any) *gomock.Call

Comment indicates an expected call of Comment.

func (*MockClientMockRecorder) CommentClose

func (mr *MockClientMockRecorder) CommentClose(ctx, owner, repo, number, key any) *gomock.Call

CommentClose indicates an expected call of CommentClose.

func (*MockClientMockRecorder) CommentUpdate

func (mr *MockClientMockRecorder) CommentUpdate(ctx, owner, repo, number, key, body any) *gomock.Call

CommentUpdate indicates an expected call of CommentUpdate.

func (*MockClientMockRecorder) FetchRepositoryMetadata

func (mr *MockClientMockRecorder) FetchRepositoryMetadata(ctx, identifier any) *gomock.Call

FetchRepositoryMetadata indicates an expected call of FetchRepositoryMetadata.

func (*MockClientMockRecorder) GetPullRequest

func (mr *MockClientMockRecorder) GetPullRequest(ctx, owner, repo, number any) *gomock.Call

GetPullRequest indicates an expected call of GetPullRequest.

func (*MockClientMockRecorder) MergePR

func (mr *MockClientMockRecorder) MergePR(ctx, owner, repo, number, headSHA any) *gomock.Call

MergePR indicates an expected call of MergePR.

func (*MockClientMockRecorder) SetStatus

func (mr *MockClientMockRecorder) SetStatus(ctx, owner, repo, sha, state, description, targetURL any) *gomock.Call

SetStatus indicates an expected call of SetStatus.

type PullRequest

type PullRequest struct {
	Number     int
	HeadSHA    string
	BaseRef    string
	Author     string
	State      string
	IsMerged   bool
	IsApproved bool
	UpdatedAt  time.Time
}

type WebhookEvent

type WebhookEvent struct {
	Type     string
	Repo     string
	PRNumber int
	Sender   string
	Body     string
}

WebhookEvent normalizado

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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