Documentation
¶
Overview ¶
Package provider defines the VCS provider interface and implementations for interacting with GitHub and GitLab APIs.
Index ¶
- Constants
- Variables
- func DetectProviderType(host string) (string, error)
- func ParseCommits(entries []CommitEntry) []commit.Commit
- type CommitBoundaryNotFoundError
- type CommitEntry
- type GitHub
- func (g *GitHub) CreateBranch(ctx context.Context, name, base string) error
- func (g *GitHub) CreateRelease(ctx context.Context, opts ReleaseOptions) (*Release, error)
- func (g *GitHub) CreateReleasePR(ctx context.Context, opts ReleasePROptions) (*PullRequest, error)
- func (g *GitHub) FindMergedReleasePR(ctx context.Context, baseBranch string) (*PullRequest, error)
- func (g *GitHub) FindOpenPendingReleasePRs(ctx context.Context, baseBranch string) ([]*PullRequest, error)
- func (g *GitHub) FindReleasePR(ctx context.Context, branch string) (*PullRequest, error)
- func (g *GitHub) GetCommitsSince(ctx context.Context, ref, branch string) ([]CommitEntry, error)
- func (g *GitHub) GetFile(ctx context.Context, branch, path string) (string, error)
- func (g *GitHub) GetLatestVersionRef(ctx context.Context) (string, error)
- func (g *GitHub) GetReleaseByTag(ctx context.Context, tag string) (*Release, error)
- func (g *GitHub) ListTags(ctx context.Context) ([]string, error)
- func (g *GitHub) MarkReleasePRPending(ctx context.Context, number int) error
- func (g *GitHub) MarkReleasePRTagged(ctx context.Context, number int) error
- func (g *GitHub) MergeReleasePR(ctx context.Context, number int, opts MergeReleasePROptions) error
- func (g *GitHub) PathPrefix() string
- func (g *GitHub) RepoURL() string
- func (g *GitHub) TagExists(ctx context.Context, tag string) (bool, error)
- func (g *GitHub) UpdateFile(ctx context.Context, branch, path, content, message string) error
- func (g *GitHub) UpdateFiles(ctx context.Context, branch, base string, files map[string]string, ...) error
- func (g *GitHub) UpdateReleasePR(ctx context.Context, number int, opts ReleasePROptions) error
- type GitLab
- func (g *GitLab) CreateBranch(ctx context.Context, name, base string) error
- func (g *GitLab) CreateRelease(ctx context.Context, opts ReleaseOptions) (*Release, error)
- func (g *GitLab) CreateReleasePR(ctx context.Context, opts ReleasePROptions) (*PullRequest, error)
- func (g *GitLab) FindMergedReleasePR(ctx context.Context, baseBranch string) (*PullRequest, error)
- func (g *GitLab) FindOpenPendingReleasePRs(ctx context.Context, baseBranch string) ([]*PullRequest, error)
- func (g *GitLab) FindReleasePR(ctx context.Context, branch string) (*PullRequest, error)
- func (g *GitLab) GetCommitsSince(ctx context.Context, ref, branch string) ([]CommitEntry, error)
- func (g *GitLab) GetFile(ctx context.Context, branch, path string) (string, error)
- func (g *GitLab) GetLatestVersionRef(ctx context.Context) (string, error)
- func (g *GitLab) GetReleaseByTag(ctx context.Context, tag string) (*Release, error)
- func (g *GitLab) ListTags(ctx context.Context) ([]string, error)
- func (g *GitLab) MarkReleasePRPending(ctx context.Context, number int) error
- func (g *GitLab) MarkReleasePRTagged(ctx context.Context, number int) error
- func (g *GitLab) MergeReleasePR(ctx context.Context, number int, opts MergeReleasePROptions) error
- func (g *GitLab) PathPrefix() string
- func (g *GitLab) RepoURL() string
- func (g *GitLab) TagExists(ctx context.Context, tag string) (bool, error)
- func (g *GitLab) UpdateFile(ctx context.Context, branch, path, content, message string) error
- func (g *GitLab) UpdateFiles(ctx context.Context, branch, base string, files map[string]string, ...) error
- func (g *GitLab) UpdateReleasePR(ctx context.Context, number int, opts ReleasePROptions) error
- type MergeMethod
- type MergeReleasePROptions
- type Provider
- type PullRequest
- type Release
- type ReleaseOptions
- type ReleasePROptions
- type RepoInfo
- type RepositoryDescriptor
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 ParseCommits ¶
func ParseCommits(entries []CommitEntry) []commit.Commit
Types ¶
type CommitBoundaryNotFoundError ¶ added in v0.1.3
CommitBoundaryNotFoundError includes the missing boundary ref and the branch being analyzed.
func (*CommitBoundaryNotFoundError) Error ¶ added in v0.1.3
func (e *CommitBoundaryNotFoundError) Error() string
func (*CommitBoundaryNotFoundError) Unwrap ¶ added in v0.1.3
func (e *CommitBoundaryNotFoundError) Unwrap() error
type CommitEntry ¶
type GitHub ¶
type GitHub struct {
// contains filtered or unexported fields
}
func (*GitHub) CreateBranch ¶
func (*GitHub) CreateRelease ¶
func (*GitHub) CreateReleasePR ¶
func (g *GitHub) CreateReleasePR(ctx context.Context, opts ReleasePROptions) (*PullRequest, error)
func (*GitHub) FindMergedReleasePR ¶
func (*GitHub) FindOpenPendingReleasePRs ¶
func (*GitHub) FindReleasePR ¶
FindReleasePR returns ErrNoPR if no open release PR is found.
func (*GitHub) GetCommitsSince ¶
func (*GitHub) GetLatestVersionRef ¶ added in v0.2.2
func (*GitHub) GetReleaseByTag ¶ added in v0.2.2
func (*GitHub) MarkReleasePRPending ¶
func (*GitHub) MarkReleasePRTagged ¶
func (*GitHub) MergeReleasePR ¶ added in v0.1.2
func (*GitHub) PathPrefix ¶
func (*GitHub) UpdateFile ¶
func (*GitHub) UpdateFiles ¶
func (*GitHub) UpdateReleasePR ¶
type GitLab ¶
type GitLab struct {
// contains filtered or unexported fields
}
func NewGitLab ¶
NewGitLab creates a provider. pid is the project ID or full path (e.g., "owner/repo").
func (*GitLab) CreateBranch ¶
func (*GitLab) CreateRelease ¶
func (*GitLab) CreateReleasePR ¶
func (g *GitLab) CreateReleasePR(ctx context.Context, opts ReleasePROptions) (*PullRequest, error)
func (*GitLab) FindMergedReleasePR ¶
func (*GitLab) FindOpenPendingReleasePRs ¶
func (*GitLab) FindReleasePR ¶
func (*GitLab) GetCommitsSince ¶
func (*GitLab) GetLatestVersionRef ¶ added in v0.2.2
func (*GitLab) GetReleaseByTag ¶ added in v0.2.2
func (*GitLab) MarkReleasePRPending ¶
func (*GitLab) MarkReleasePRTagged ¶
func (*GitLab) MergeReleasePR ¶ added in v0.1.2
func (*GitLab) PathPrefix ¶
func (*GitLab) UpdateFile ¶
func (*GitLab) UpdateFiles ¶
func (*GitLab) UpdateReleasePR ¶
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 ReleaseOptions ¶
type ReleasePROptions ¶
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)
Click to show internal directories.
Click to hide internal directories.