provider

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package provider defines the VCS provider interface and implementations for interacting with GitHub and GitLab APIs.

Index

Constants

View Source
const DefaultGitHubHost = "github.com"
View Source
const DefaultGitLabHost = "gitlab.com"
View Source
const ReleaseLabelPending = "autorelease: pending"
View Source
const ReleaseLabelTagged = "autorelease: tagged"

Variables

View Source
var ErrCommitBoundaryNotFound = errors.New("commit boundary not found")

ErrCommitBoundaryNotFound reports that the requested base ref is not reachable from the target branch history.

View Source
var ErrEmptyCommitID = errors.New("empty commit ID")
View Source
var ErrEmptyCommitSHA = errors.New("empty commit SHA")
View Source
var ErrFileNotFound = errors.New("file not found")
View Source
var ErrMergeBlocked = errors.New("release PR merge blocked")
View Source
var ErrMergeMethodUnsupported = errors.New("merge method unsupported")
View Source
var ErrNoPR = errors.New("no release PR found")
View Source
var ErrNoRelease = errors.New("no release found")
View Source
var ErrNoVersionRef = errors.New("no version ref found")
View Source
var ErrUnknownRemote = errors.New("unable to parse remote URL")
View Source
var ErrUnsupportedHost = errors.New("unsupported remote host")

Functions

func DetectProviderType added in v0.1.3

func DetectProviderType(host string) (string, error)

func ParseCommits

func ParseCommits(entries []CommitEntry) []commit.Commit

Types

type CommitBoundaryNotFoundError added in v0.1.3

type CommitBoundaryNotFoundError struct {
	Ref    string
	Branch string
}

CommitBoundaryNotFoundError includes the missing boundary ref and the branch being analyzed.

func (*CommitBoundaryNotFoundError) Error added in v0.1.3

func (*CommitBoundaryNotFoundError) Unwrap added in v0.1.3

func (e *CommitBoundaryNotFoundError) Unwrap() error

type CommitEntry

type CommitEntry struct {
	Hash    string
	Message string
}

type GitHub

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

func NewGitHub

func NewGitHub(client *github.Client, owner, repo string) *GitHub

func (*GitHub) CreateBranch

func (g *GitHub) CreateBranch(ctx context.Context, name, base string) error

func (*GitHub) CreateRelease

func (g *GitHub) CreateRelease(ctx context.Context, opts ReleaseOptions) (*Release, error)

func (*GitHub) CreateReleasePR

func (g *GitHub) CreateReleasePR(ctx context.Context, opts ReleasePROptions) (*PullRequest, error)

func (*GitHub) FindMergedReleasePR

func (g *GitHub) FindMergedReleasePR(ctx context.Context, baseBranch string) (*PullRequest, error)

func (*GitHub) FindOpenPendingReleasePRs

func (g *GitHub) FindOpenPendingReleasePRs(ctx context.Context, baseBranch string) ([]*PullRequest, error)

func (*GitHub) FindReleasePR

func (g *GitHub) FindReleasePR(ctx context.Context, branch string) (*PullRequest, error)

FindReleasePR returns ErrNoPR if no open release PR is found.

func (*GitHub) GetCommitsSince

func (g *GitHub) GetCommitsSince(ctx context.Context, ref, branch string) ([]CommitEntry, error)

func (*GitHub) GetFile

func (g *GitHub) GetFile(ctx context.Context, branch, path string) (string, error)

func (*GitHub) GetLatestVersionRef added in v0.2.2

func (g *GitHub) GetLatestVersionRef(ctx context.Context) (string, error)

func (*GitHub) GetReleaseByTag added in v0.2.2

func (g *GitHub) GetReleaseByTag(ctx context.Context, tag string) (*Release, error)

func (*GitHub) ListTags added in v0.2.2

func (g *GitHub) ListTags(ctx context.Context) ([]string, error)

func (*GitHub) MarkReleasePRPending

func (g *GitHub) MarkReleasePRPending(ctx context.Context, number int) error

func (*GitHub) MarkReleasePRTagged

func (g *GitHub) MarkReleasePRTagged(ctx context.Context, number int) error

func (*GitHub) MergeReleasePR added in v0.1.2

func (g *GitHub) MergeReleasePR(ctx context.Context, number int, opts MergeReleasePROptions) error

func (*GitHub) PathPrefix

func (g *GitHub) PathPrefix() string

func (*GitHub) RepoURL

func (g *GitHub) RepoURL() string

func (*GitHub) TagExists added in v0.2.2

func (g *GitHub) TagExists(ctx context.Context, tag string) (bool, error)

func (*GitHub) UpdateFile

func (g *GitHub) UpdateFile(ctx context.Context, branch, path, content, message string) error

func (*GitHub) UpdateFiles

func (g *GitHub) UpdateFiles(ctx context.Context, branch, base string, files map[string]string, message string) error

func (*GitHub) UpdateReleasePR

func (g *GitHub) UpdateReleasePR(ctx context.Context, number int, opts ReleasePROptions) error

type GitLab

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

func NewGitLab

func NewGitLab(client *gitlab.Client, project string) *GitLab

NewGitLab creates a provider. pid is the project ID or full path (e.g., "owner/repo").

func (*GitLab) CreateBranch

func (g *GitLab) CreateBranch(ctx context.Context, name, base string) error

func (*GitLab) CreateRelease

func (g *GitLab) CreateRelease(ctx context.Context, opts ReleaseOptions) (*Release, error)

func (*GitLab) CreateReleasePR

func (g *GitLab) CreateReleasePR(ctx context.Context, opts ReleasePROptions) (*PullRequest, error)

func (*GitLab) FindMergedReleasePR

func (g *GitLab) FindMergedReleasePR(ctx context.Context, baseBranch string) (*PullRequest, error)

func (*GitLab) FindOpenPendingReleasePRs

func (g *GitLab) FindOpenPendingReleasePRs(ctx context.Context, baseBranch string) ([]*PullRequest, error)

func (*GitLab) FindReleasePR

func (g *GitLab) FindReleasePR(ctx context.Context, branch string) (*PullRequest, error)

func (*GitLab) GetCommitsSince

func (g *GitLab) GetCommitsSince(ctx context.Context, ref, branch string) ([]CommitEntry, error)

func (*GitLab) GetFile

func (g *GitLab) GetFile(ctx context.Context, branch, path string) (string, error)

func (*GitLab) GetLatestVersionRef added in v0.2.2

func (g *GitLab) GetLatestVersionRef(ctx context.Context) (string, error)

func (*GitLab) GetReleaseByTag added in v0.2.2

func (g *GitLab) GetReleaseByTag(ctx context.Context, tag string) (*Release, error)

func (*GitLab) ListTags added in v0.2.2

func (g *GitLab) ListTags(ctx context.Context) ([]string, error)

func (*GitLab) MarkReleasePRPending

func (g *GitLab) MarkReleasePRPending(ctx context.Context, number int) error

func (*GitLab) MarkReleasePRTagged

func (g *GitLab) MarkReleasePRTagged(ctx context.Context, number int) error

func (*GitLab) MergeReleasePR added in v0.1.2

func (g *GitLab) MergeReleasePR(ctx context.Context, number int, opts MergeReleasePROptions) error

func (*GitLab) PathPrefix

func (g *GitLab) PathPrefix() string

func (*GitLab) RepoURL

func (g *GitLab) RepoURL() string

func (*GitLab) TagExists added in v0.2.2

func (g *GitLab) TagExists(ctx context.Context, tag string) (bool, error)

func (*GitLab) UpdateFile

func (g *GitLab) UpdateFile(ctx context.Context, branch, path, content, message string) error

func (*GitLab) UpdateFiles

func (g *GitLab) UpdateFiles(ctx context.Context, branch, base string, files map[string]string, message string) error

func (*GitLab) UpdateReleasePR

func (g *GitLab) UpdateReleasePR(ctx context.Context, number int, opts ReleasePROptions) error

type MergeMethod added in v0.1.2

type MergeMethod = string
const (
	MergeMethodAuto   MergeMethod = "auto"
	MergeMethodSquash MergeMethod = "squash"
	MergeMethodRebase MergeMethod = "rebase"
	MergeMethodMerge  MergeMethod = "merge"
)

type MergeReleasePROptions added in v0.1.2

type MergeReleasePROptions struct {
	Force  bool
	Method MergeMethod
}

type Provider

type Provider interface {
	// GetLatestVersionRef returns the preferred release/tag baseline candidate.
	GetLatestVersionRef(ctx context.Context) (string, error)
	// ListTags returns repository tags.
	ListTags(ctx context.Context) ([]string, error)
	// GetReleaseByTag returns the release for the exact tag.
	GetReleaseByTag(ctx context.Context, tag string) (*Release, error)
	// TagExists reports whether the exact tag already exists.
	TagExists(ctx context.Context, tag string) (bool, error)
	// GetCommitsSince returns commits on the given branch since the given ref (tag or SHA).
	GetCommitsSince(ctx context.Context, ref, branch string) ([]CommitEntry, error)
	// CreateReleasePR creates a release PR/MR.
	CreateReleasePR(ctx context.Context, opts ReleasePROptions) (*PullRequest, error)
	// UpdateReleasePR updates an existing release PR/MR.
	UpdateReleasePR(ctx context.Context, number int, opts ReleasePROptions) error
	// FindOpenPendingReleasePRs finds open release PRs/MRs labeled pending for the base branch.
	FindOpenPendingReleasePRs(ctx context.Context, baseBranch string) ([]*PullRequest, error)
	// FindReleasePR finds an existing open release PR/MR.
	FindReleasePR(ctx context.Context, branch string) (*PullRequest, error)
	// FindMergedReleasePR finds the latest merged release PR/MR waiting for tagging.
	FindMergedReleasePR(ctx context.Context, baseBranch string) (*PullRequest, error)
	// CreateRelease creates a release with a tag.
	CreateRelease(ctx context.Context, opts ReleaseOptions) (*Release, error)
	// MergeReleasePR merges an existing release PR/MR.
	MergeReleasePR(ctx context.Context, number int, opts MergeReleasePROptions) error
	// MarkReleasePRPending marks a release PR/MR as waiting for tagging.
	MarkReleasePRPending(ctx context.Context, number int) error
	// MarkReleasePRTagged marks a release PR/MR as tagged.
	MarkReleasePRTagged(ctx context.Context, number int) error
	// CreateBranch creates a new branch from the base branch.
	CreateBranch(ctx context.Context, name, base string) error
	// GetFile reads a file content from a branch.
	GetFile(ctx context.Context, branch, path string) (string, error)
	// UpdateFile creates or updates a file on a branch.
	UpdateFile(ctx context.Context, branch, path, content, message string) error
	// UpdateFiles force-updates a branch from base with one commit containing all file changes.
	UpdateFiles(ctx context.Context, branch, base string, files map[string]string, message string) error
	// RepoURL returns the HTTPS base URL for the repository.
	RepoURL() string
	// PathPrefix returns the path prefix for commit/compare URLs (empty for GitHub, "/-" for GitLab).
	PathPrefix() string
}

type PullRequest

type PullRequest struct {
	Number         int
	Title          string
	Body           string
	URL            string
	Branch         string
	MergeCommitSHA string
}

type Release

type Release struct {
	TagName string
	Name    string
	Body    string
	URL     string
}

type ReleaseOptions

type ReleaseOptions struct {
	TagName string
	Ref     string
	Name    string
	Body    string
}

type ReleasePROptions

type ReleasePROptions struct {
	Title         string
	Body          string
	BaseBranch    string
	ReleaseBranch string
	Files         map[string]string
}

type RepoInfo

type RepoInfo struct {
	Owner string
	Name  string
}

type RepositoryDescriptor added in v0.1.3

type RepositoryDescriptor struct {
	Provider string
	Host     string
	Owner    string
	Repo     string
	Project  string
	Remote   string
}

func ParseRemote added in v0.1.3

func ParseRemote(remoteURL string) (*RepositoryDescriptor, error)

Jump to

Keyboard shortcuts

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