hosting

package
v9.0.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package hosting provides support for interacting with code hosting services. Commands like "new-pull-request", "repo", and "ship" use this package to know how to perform Git Town operations on GitHub, Gitlab, Bitbucket, etc. Implementations of connectors for particular code hosting platforms conform to the Connector interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterGiteaPullRequests

func FilterGiteaPullRequests(pullRequests []*gitea.PullRequest, organization, branch, target string) []*gitea.PullRequest

func ParseCommitMessage

func ParseCommitMessage(message string) (title, body string)

func UnsupportedServiceError

func UnsupportedServiceError() error

UnsupportedServiceError communicates that the origin remote runs an unknown code hosting service.

Types

type BitbucketConnector

type BitbucketConnector struct {
	CommonConfig
	// contains filtered or unexported fields
}

BitbucketConnector provides access to the API of Bitbucket installations.

func NewBitbucketConnector

func NewBitbucketConnector(gitConfig gitTownConfig, git gitCommands) (*BitbucketConnector, error)

NewBitbucketConnector provides a Bitbucket connector instance if the current repo is hosted on Bitbucket, otherwise nil.

func (*BitbucketConnector) DefaultProposalMessage

func (c *BitbucketConnector) DefaultProposalMessage(proposal Proposal) string

func (*BitbucketConnector) FindProposal

func (c *BitbucketConnector) FindProposal(branch, target string) (*Proposal, error)

func (*BitbucketConnector) HostingServiceName

func (c *BitbucketConnector) HostingServiceName() string

func (*BitbucketConnector) NewProposalURL

func (c *BitbucketConnector) NewProposalURL(branch, parentBranch string) (string, error)

func (*BitbucketConnector) RepositoryURL

func (c *BitbucketConnector) RepositoryURL() string

func (*BitbucketConnector) SquashMergeProposal

func (c *BitbucketConnector) SquashMergeProposal(number int, message string) (mergeSHA string, err error)

func (*BitbucketConnector) UpdateProposalTarget

func (c *BitbucketConnector) UpdateProposalTarget(number int, target string) error

type CommonConfig

type CommonConfig struct {
	// bearer token to authenticate with the API
	APIToken string

	// Hostname override
	Hostname string

	// the Organization within the hosting platform that owns the repo
	Organization string

	// repo name within the organization
	Repository string
}

CommonConfig contains data needed by all platform connectors.

type Connector

type Connector interface {
	// DefaultProposalMessage provides the text that the form for creating new proposals
	// on the respective hosting platform is prepopulated with.
	DefaultProposalMessage(proposal Proposal) string

	// FindProposal provides details about the proposal for the given branch into the given target branch.
	// Returns nil if no proposal exists.
	FindProposal(branch, target string) (*Proposal, error)

	// HostingServiceName provides the name of the code hosting service
	// supported by the respective connector implementation.
	HostingServiceName() string

	// SquashMergeProposal squash-merges the proposal with the given number
	// using the given commit message.
	SquashMergeProposal(number int, message string) (mergeSHA string, err error)

	// NewProposalURL provides the URL of the page
	// to create a new proposal online.
	NewProposalURL(branch, parentBranch string) (string, error)

	// RepositoryURL provides the URL where the current repository can be found online.
	RepositoryURL() string

	// UpdateProposalTarget updates the target branch of the given proposal.
	UpdateProposalTarget(number int, target string) error
}

Connector describes the activities that Git Town performs on code hosting platforms via their API. Individual implementations exist to talk to specific hosting platforms. They all conform to this interface.

func NewConnector

func NewConnector(config gitTownConfig, git gitCommands, log logFn) (Connector, error)

NewConnector provides an instance of the code hosting connector to use based on the given gitConfig.

type GitHubConnector

type GitHubConnector struct {
	CommonConfig
	MainBranch string
	// contains filtered or unexported fields
}

GitHubConnector provides standardized connectivity for the given repository (github.com/owner/repo) via the GitHub API.

func NewGithubConnector

func NewGithubConnector(gitConfig gitTownConfig, log logFn) (*GitHubConnector, error)

NewGithubConnector provides a fully configured GithubConnector instance if the current repo is hosted on Github, otherwise nil.

func (*GitHubConnector) DefaultProposalMessage

func (c *GitHubConnector) DefaultProposalMessage(proposal Proposal) string

func (*GitHubConnector) FindProposal

func (c *GitHubConnector) FindProposal(branch, target string) (*Proposal, error)

func (*GitHubConnector) HostingServiceName

func (c *GitHubConnector) HostingServiceName() string

func (*GitHubConnector) NewProposalURL

func (c *GitHubConnector) NewProposalURL(branch, parentBranch string) (string, error)

func (*GitHubConnector) RepositoryURL

func (c *GitHubConnector) RepositoryURL() string

func (*GitHubConnector) SquashMergeProposal

func (c *GitHubConnector) SquashMergeProposal(number int, message string) (mergeSHA string, err error)

func (*GitHubConnector) UpdateProposalTarget

func (c *GitHubConnector) UpdateProposalTarget(number int, target string) error

type GitLabConfig

type GitLabConfig struct {
	CommonConfig
}

func (*GitLabConfig) DefaultProposalMessage

func (c *GitLabConfig) DefaultProposalMessage(proposal Proposal) string

func (*GitLabConfig) HostingServiceName

func (c *GitLabConfig) HostingServiceName() string

func (*GitLabConfig) NewProposalURL

func (c *GitLabConfig) NewProposalURL(branch, parentBranch string) (string, error)

func (*GitLabConfig) RepositoryURL

func (c *GitLabConfig) RepositoryURL() string

type GitLabConnector

type GitLabConnector struct {
	GitLabConfig
	// contains filtered or unexported fields
}

GitLabConnector provides standardized connectivity for the given repository (gitlab.com/owner/repo) via the GitLab API.

func NewGitlabConnector

func NewGitlabConnector(gitConfig gitTownConfig, log logFn) (*GitLabConnector, error)

NewGitlabConfig provides GitLab configuration data if the current repo is hosted on GitLab, otherwise nil.

func (*GitLabConnector) FindProposal

func (c *GitLabConnector) FindProposal(branch, target string) (*Proposal, error)

func (*GitLabConnector) SquashMergeProposal

func (c *GitLabConnector) SquashMergeProposal(number int, message string) (mergeSHA string, err error)

func (*GitLabConnector) UpdateProposalTarget

func (c *GitLabConnector) UpdateProposalTarget(number int, target string) error

type GiteaConnector

type GiteaConnector struct {
	CommonConfig
	// contains filtered or unexported fields
}

func NewGiteaConnector

func NewGiteaConnector(gitConfig gitTownConfig, log logFn) (*GiteaConnector, error)

NewGiteaConfig provides Gitea configuration data if the current repo is hosted on Gitea, otherwise nil.

func (*GiteaConnector) DefaultProposalMessage

func (c *GiteaConnector) DefaultProposalMessage(proposal Proposal) string

func (*GiteaConnector) FindProposal

func (c *GiteaConnector) FindProposal(branch, target string) (*Proposal, error)

func (*GiteaConnector) HostingServiceName

func (c *GiteaConnector) HostingServiceName() string

func (*GiteaConnector) NewProposalURL

func (c *GiteaConnector) NewProposalURL(branch, parentBranch string) (string, error)

func (*GiteaConnector) RepositoryURL

func (c *GiteaConnector) RepositoryURL() string

func (*GiteaConnector) SquashMergeProposal

func (c *GiteaConnector) SquashMergeProposal(number int, message string) (mergeSha string, err error)

func (*GiteaConnector) UpdateProposalTarget

func (c *GiteaConnector) UpdateProposalTarget(number int, target string) error

type Proposal

type Proposal struct {
	// the number used to identify the proposal on the hosting platform
	Number int

	// name of the target branch ("base") of this proposal
	Target string

	// textual title of the proposal
	Title string

	// whether this proposal can be merged via the API
	CanMergeWithAPI bool
}

Proposal contains information about a change request on a code hosting platform. Alternative names are "pull request" or "merge request".

Jump to

Keyboard shortcuts

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