scm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package scm provides provider-neutral contracts, model types, and validation helpers for repository and pull-request operations.

Provider packages implement this package's interfaces so command logic can interact with multiple SCM providers through a common abstraction layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, factory ProviderFactory)

Register a new SCM provider factory by name.

func ValidatePROptions added in v0.11.0

func ValidatePROptions(caps *Capabilities, opts *PROptions) error

ValidatePROptions validates that the provided PR options are supported by the given capabilities.

Types

type Capabilities added in v0.11.0

type Capabilities struct {
	TeamReviewers  bool
	ResetReviewers bool
	Draft          bool

	MergeMethods   []string
	CheckMergeable bool
}

Capabilities defines which PR options are supported by a provider.

type PRMergeOptions added in v0.11.0

type PRMergeOptions struct {
	Method         string
	CheckMergeable bool
}

PRMergeOptions holds options for merging pull requests.

type PROptions added in v0.11.0

type PROptions struct {
	Title          string
	Description    string
	Reviewers      []string
	TeamReviewers  []string
	ResetReviewers bool
	BaseBranch     string
	Draft          *bool

	Merge PRMergeOptions
}

PROptions holds options for creating or updating pull requests.

type Provider

type Provider interface {
	// CheckCapabilities validates that the provided PR options are supported by the provider.
	CheckCapabilities(opts *PROptions) error

	// ListRepositories lists all repositories in the specified project.
	ListRepositories() ([]*Repository, error)

	// GetPullRequest retrieves a pull request by repository name and source branch.
	GetPullRequest(repo, branch string) (*PullRequest, error)
	// OpenPullRequest opens a new pull request in the specified repository.
	OpenPullRequest(repo, branch string, opts *PROptions) (*PullRequest, error)
	// UpdatePullRequest updates an existing pull request.
	UpdatePullRequest(repo, branch string, opts *PROptions) (*PullRequest, error)
	// MergePullRequest merges an existing pull request.
	MergePullRequest(repo, branch string, opts *PRMergeOptions) (*PullRequest, error)
}

Provider defines the interface for SCM providers.

func Get

func Get(ctx context.Context, name, project string) Provider

Get retrieves a registered SCM provider by name. If the provider is not registered, it panics.

type ProviderFactory

type ProviderFactory func(ctx context.Context, project string) Provider

ProviderFactory is a function that creates a new Provider instance.

type PullRequest

type PullRequest struct {
	Title         string   `json:"title"`
	Description   string   `json:"description"`
	Branch        string   `json:"branch"`
	BaseBranch    string   `json:"base_branch,omitempty"`
	Repo          string   `json:"repo,omitempty"`
	Reviewers     []string `json:"reviewers,omitempty"`
	TeamReviewers []string `json:"team_reviewers,omitempty"`

	ID        int  `json:"id"`
	Number    int  `json:"number"`
	Version   int  `json:"version,omitempty"`
	Draft     bool `json:"draft,omitempty"`
	Mergeable bool `json:"mergeable"`
}

PullRequest represents a pull request in a repository.

type Repository

type Repository struct {
	Name          string   `json:"name"`
	Description   string   `json:"description"`
	Public        bool     `json:"public"`
	Archived      bool     `json:"archived,omitempty"`
	Project       string   `json:"project"`
	DefaultBranch string   `json:"default_branch"`
	Labels        []string `json:"labels,omitempty"`
}

Repository represents a source code repository.

Directories

Path Synopsis
Package bitbucket implements the scm.Provider contract against Bitbucket APIs.
Package bitbucket implements the scm.Provider contract against Bitbucket APIs.
Package fake provides an in-memory scm.Provider implementation for tests and local examples.
Package fake provides an in-memory scm.Provider implementation for tests and local examples.
Package github implements the scm.Provider contract for GitHub repositories and pull-request workflows.
Package github implements the scm.Provider contract for GitHub repositories and pull-request workflows.

Jump to

Keyboard shortcuts

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