scm

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

Source Control Managers

This folder contains all Source Control Managers. They do all implement the VersionController interface described below.

type VersionController interface {
	// Should get repositories based on the scm configuration
	GetRepositories(ctx context.Context) ([]scm.Repository, error)
	// Creates a pull request. The repo parameter will always originate from the same package
	CreatePullRequest(ctx context.Context, repo scm.Repository, prRepo scm.Repository, newPR scm.NewPullRequest) (scm.PullRequest, error)
	// Gets the latest pull requests from repositories based on the scm configuration
	GetPullRequests(ctx context.Context, branchName string) ([]scm.PullRequest, error)
	// Merges a pull request, the pr parameter will always originate from the same package
	MergePullRequest(ctx context.Context, pr scm.PullRequest) error
	// Close a pull request, the pr parameter will always originate from the same package
	ClosePullRequest(ctx context.Context, pr scm.PullRequest) error
	// ForkRepository forks a repository. If newOwner is set, use it, otherwise fork to the current user
	ForkRepository(ctx context.Context, repo scm.Repository, newOwner string) (scm.Repository, error)
}

Autocompletion

The version controller can also implement additional functions to support features such as shell-autocompletion. The following functions can be implemented independently and will automatically be used for tab completions when the user has activated it.

func GetAutocompleteOrganizations(ctx context.Context, search string) ([]string, error)
func GetAutocompleteUsers(ctx context.Context, search string) ([]string, error)
func GetAutocompleteRepositories(ctx context.Context, search string) ([]string, error)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff added in v0.50.0

func Diff[T comparable](s1, s2 []T) (added, removed []T)

Diff two slices and get the added and removed items compared to s1

func Map added in v0.50.0

func Map[T any, K any](vals []T, mapping func(T) K) []K

Map runs a function for each value in a slice and returns a slice of all function returns

func RepoContainsTopic added in v0.44.0

func RepoContainsTopic(repoTopics []string, filterTopics []string) bool

Types

type MergeType

type MergeType int

MergeType is the way a pull request is "merged" into the base branch

const (
	MergeTypeUnknown MergeType = iota
	MergeTypeMerge
	MergeTypeRebase
	MergeTypeSquash
)

All MergeTypes

func MergeTypeIntersection

func MergeTypeIntersection(mergeTypes1, mergeTypes2 []MergeType) []MergeType

MergeTypeIntersection calculates the intersection of two merge type slices, The order of the first slice will be preserved

func ParseMergeType

func ParseMergeType(typ string) (MergeType, error)

ParseMergeType parses a merge type

type NewPullRequest

type NewPullRequest struct {
	Title string
	Body  string
	Head  string
	Base  string

	Reviewers     []string // The username of all reviewers
	TeamReviewers []string // Teams to assign as reviewers
	Assignees     []string
	Draft         bool
	Labels        []string
}

NewPullRequest is the data needed to create a new pull request

type PullRequest

type PullRequest interface {
	Status() PullRequestStatus
	String() string
}

PullRequest represents a pull request

type PullRequestStatus

type PullRequestStatus int

PullRequestStatus is the status of a pull request, including statuses of the last commit

const (
	PullRequestStatusUnknown PullRequestStatus = iota
	PullRequestStatusSuccess
	PullRequestStatusPending
	PullRequestStatusError
	PullRequestStatusMerged
	PullRequestStatusClosed
)

All PullRequestStatuses

func (PullRequestStatus) String

func (s PullRequestStatus) String() string

type Repository

type Repository interface {
	// CloneURL returns the clone address of the repository
	CloneURL() string
	// DefaultBranch returns the name of the default branch of the repository
	DefaultBranch() string
	// FullName returns the full id of the repository, usually ownerName/repoName
	FullName() string
}

Repository provides all the information needed about a git repository

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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