vcs

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Names

func Names() []string

Names returns all registered VCS provider names from the global registry.

func Register

func Register(name string, f Factory)

Register adds a VCS provider factory to the global registry.

Types

type DiffRefs

type DiffRefs struct {
	BaseSHA  string
	HeadSHA  string
	StartSHA string
}

DiffRefs holds the SHA references needed for inline comments.

type Factory

type Factory func(token, baseURL string) (VCSProvider, error)

Factory creates a VCSProvider from a token and base URL.

type FileDiff

type FileDiff struct {
	OldPath     string
	NewPath     string
	Diff        string
	NewFile     bool
	RenamedFile bool
	DeletedFile bool
	AMode       string
	BMode       string
}

FileDiff represents a single file's diff in a merge/pull request.

type InlineComment

type InlineComment struct {
	FilePath string
	OldPath  string
	NewLine  int64
	OldLine  int64
	Body     string
}

InlineComment holds data for posting an inline comment on a diff.

type MRDiscussion added in v0.0.7

type MRDiscussion struct {
	ID    string
	Notes []MRDiscussionNote
}

MRDiscussion represents one MR discussion thread.

type MRDiscussionNote added in v0.0.7

type MRDiscussionNote struct {
	ID         int64
	Author     string
	Body       string
	FilePath   string
	Line       int
	Resolved   bool
	Resolvable bool
}

MRDiscussionNote represents one note in an MR discussion.

type MRNote added in v0.0.7

type MRNote struct {
	ID     int64
	Author string
	Body   string
}

MRNote represents one top-level MR note/comment (non-thread).

type MergeRequest

type MergeRequest struct {
	IID          int64
	Title        string
	Description  string
	Author       string
	SourceBranch string
	TargetBranch string
	State        string
	WebURL       string
	DiffRefs     DiffRefs
}

MergeRequest holds platform-agnostic merge/pull request metadata.

type Pipeline

type Pipeline struct {
	ID     int64
	Status string
	Ref    string
	WebURL string
}

Pipeline holds basic CI pipeline info.

type ProviderInfo

type ProviderInfo struct {
	Name    string
	BaseURL string
}

ProviderInfo describes a VCS provider.

type Registry

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

Registry is a thread-safe store of VCS provider factories.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty Registry.

func (*Registry) Get

func (r *Registry) Get(name string, token, baseURL string) (VCSProvider, error)

Get creates a VCS provider instance by name.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns a sorted list of registered VCS provider names.

func (*Registry) Register

func (r *Registry) Register(name string, f Factory)

Register adds a VCS provider factory under the given name. It panics if the name is already registered.

type VCSProvider

type VCSProvider interface {
	Info() ProviderInfo
	FetchMR(ctx context.Context, projectID string, mrIID int64) (*MergeRequest, error)
	FetchMRDiffs(ctx context.Context, projectID string, mrIID int64) ([]FileDiff, error)
	FetchMRRawDiff(ctx context.Context, projectID string, mrIID int64) (string, error)
	ListMRDiscussions(ctx context.Context, projectID string, mrIID int64) ([]MRDiscussion, error)
	ListMRNotes(ctx context.Context, projectID string, mrIID int64) ([]MRNote, error)
	ListOpenMRs(ctx context.Context, projectID string) ([]*MergeRequest, error)
	PostSummaryNote(ctx context.Context, projectID string, mrIID int64, body string) error
	PostInlineComment(ctx context.Context, projectID string, mrIID int64, refs DiffRefs, comment InlineComment) error
	ReplyToMRDiscussion(ctx context.Context, projectID string, mrIID int64, discussionID, body string) error
	FormatSuggestionBlock(suggestion string) string
	Validate() error
}

VCSProvider abstracts version control system operations (GitLab, GitHub, etc.).

func Get

func Get(name string, token, baseURL string) (VCSProvider, error)

Get resolves a VCS provider by name from the global registry.

Directories

Path Synopsis
Package init triggers VCS provider registration via import side-effects.
Package init triggers VCS provider registration via import side-effects.

Jump to

Keyboard shortcuts

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