scm

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(client *http.Client, req *http.Request) error

Do executes the HTTP request and returns an error if the response status code is not successful.

func DoResp

func DoResp[T any](client *http.Client, req *http.Request) (*T, error)

DoResp executes the HTTP request and unmarshals the response into the provided type.

func Register

func Register(name string, factory ProviderFactory)

Register a new SCM provider factory by name.

Types

type Provider

type Provider interface {
	// 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, title, description string, reviewers []string) (PullRequest, error)
	// UpdatePullRequest updates an existing pull request.
	UpdatePullRequest(repo, branch, title, description string, reviewers []string, appendReviewers bool) (PullRequest, error)
	// MergePullRequest merges an existing pull request.
	MergePullRequest(repo, branch string) (PullRequest, error)
}

Provider defines the interface for SCM providers.

func Get

func Get(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(project string) Provider

type PullRequest

type PullRequest map[string]any

func (PullRequest) AddReviewers

func (pr PullRequest) AddReviewers(reviewers []string)

AddReviewers appends the given list of reviewers to the PR

func (PullRequest) GetReviewers

func (pr PullRequest) GetReviewers() []string

GetReviewers returns the list of reviewers for the PR

func (PullRequest) ID

func (pr PullRequest) ID() int

ID of the PR

func (PullRequest) SetReviewers

func (pr PullRequest) SetReviewers(reviewers []string)

SetReviewers sets the PR reviewers to the given list

func (PullRequest) Version

func (pr PullRequest) Version() int

Version of the PR

type Repository

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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