Documentation
¶
Overview ¶
Package forgedomain provides the domain model for forges.
Index ¶
- func CommitBody(data ProposalData, title string) string
- func IsBitbucket(forgeTypeOpt Option[DetectedForgeType]) bool
- func ParseBitbucketAPIToken(value stringss.Trimmed) Option[BitbucketAPIToken]
- func ParseBitbucketUsername(value stringss.Trimmed) Option[BitbucketUsername]
- func ParseForgeType(name stringss.Trimmed, source string) (Option[ForgeType], error)
- func ParseForgejoToken(value stringss.Trimmed) Option[ForgejoToken]
- func ParseGiteaToken(value stringss.Trimmed) Option[GiteaToken]
- func ParseGithubConnectorType(text stringss.Trimmed, source string) (Option[GithubConnectorType], error)
- func ParseGithubToken(value stringss.Trimmed) Option[GithubToken]
- func ParseGitlabConnectorType(text stringss.Trimmed, source string) (Option[GitlabConnectorType], error)
- func ParseGitlabToken(value stringss.Trimmed) Option[GitlabToken]
- func ProposalReferenceFallback(proposal ProposalData) string
- func UnsupportedServiceError() error
- type APICache
- func (self *APICache) Clear(proposalID ProposalNumber)
- func (self *APICache) Lookup(source, target gitdomain.LocalBranchName) (proposal Option[Proposal], certain bool)
- func (self *APICache) LookupSearch(source gitdomain.LocalBranchName) Option[[]Proposal]
- func (self *APICache) RegisterLookupResult(source, target gitdomain.LocalBranchName, proposal Option[Proposal])
- func (self *APICache) RegisterSearchResult(source gitdomain.LocalBranchName, proposals []Proposal)
- type BitbucketAPIToken
- type BitbucketCloudProposalData
- type BitbucketUsername
- type Connector
- type CreateProposalArgs
- type CredentialVerifier
- type DetectedForgeType
- type ForgeType
- type ForgejoToken
- type GiteaToken
- type GithubConnectorType
- type GithubToken
- type GitlabConnectorType
- type GitlabToken
- type HostedRepoInfo
- type Proposal
- type ProposalBodyUpdater
- type ProposalData
- type ProposalFinder
- type ProposalInterface
- type ProposalMerger
- type ProposalNumber
- type ProposalSearcher
- type ProposalSourceUpdater
- type ProposalTargetUpdater
- type Result
- type VerifyCredentialsResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommitBody ¶
func CommitBody(data ProposalData, title string) string
func IsBitbucket ¶
func IsBitbucket(forgeTypeOpt Option[DetectedForgeType]) bool
func ParseBitbucketAPIToken ¶
func ParseBitbucketAPIToken(value stringss.Trimmed) Option[BitbucketAPIToken]
func ParseBitbucketUsername ¶
func ParseBitbucketUsername(value stringss.Trimmed) Option[BitbucketUsername]
func ParseForgeType ¶
ParseForgeType provides the ForgeType enum matching the given text.
func ParseForgejoToken ¶
func ParseForgejoToken(value stringss.Trimmed) Option[ForgejoToken]
func ParseGiteaToken ¶
func ParseGiteaToken(value stringss.Trimmed) Option[GiteaToken]
func ParseGithubConnectorType ¶
func ParseGithubConnectorType(text stringss.Trimmed, source string) (Option[GithubConnectorType], error)
func ParseGithubToken ¶
func ParseGithubToken(value stringss.Trimmed) Option[GithubToken]
func ParseGitlabConnectorType ¶
func ParseGitlabConnectorType(text stringss.Trimmed, source string) (Option[GitlabConnectorType], error)
func ParseGitlabToken ¶
func ParseGitlabToken(value stringss.Trimmed) Option[GitlabToken]
func ProposalReferenceFallback ¶
func ProposalReferenceFallback(proposal ProposalData) string
ProposalReferenceFallback returns a portable proposal reference when there is no forge-specific shorthand available.
func UnsupportedServiceError ¶
func UnsupportedServiceError() error
UnsupportedServiceError communicates that the origin remote runs an unknown forge type.
Types ¶
type APICache ¶
type APICache struct {
// contains filtered or unexported fields
}
APICache caches results of API calls to a forge.
func (*APICache) Clear ¶
func (self *APICache) Clear(proposalID ProposalNumber)
func (*APICache) Lookup ¶
func (self *APICache) Lookup(source, target gitdomain.LocalBranchName) (proposal Option[Proposal], certain bool)
Lookup provides the proposal for the given source and target branch. Since the absence of a proposal is a valid API result, the second return value is true if the cache is certain about the result. If there is a cached proposal, returns (Some(proposal), true). If it knows there is no proposal for the given source and target branch, returns (None, true). If it has no records, returns (None, false).
func (*APICache) LookupSearch ¶
func (self *APICache) LookupSearch(source gitdomain.LocalBranchName) Option[[]Proposal]
LookupSearch provides the cached search result for the given source branch.
func (*APICache) RegisterLookupResult ¶
func (self *APICache) RegisterLookupResult(source, target gitdomain.LocalBranchName, proposal Option[Proposal])
RegisterLookupResult registers the given result of a lookup operation.
func (*APICache) RegisterSearchResult ¶
func (self *APICache) RegisterSearchResult(source gitdomain.LocalBranchName, proposals []Proposal)
RegisterSearchResult registers the given result of a search operation.
type BitbucketAPIToken ¶
func (BitbucketAPIToken) String ¶
func (self BitbucketAPIToken) String() string
type BitbucketCloudProposalData ¶
type BitbucketCloudProposalData struct {
ProposalData
CloseSourceBranch bool
Draft bool
}
func (BitbucketCloudProposalData) Data ¶
func (self BitbucketCloudProposalData) Data() ProposalData
type BitbucketUsername ¶
func (BitbucketUsername) String ¶
func (self BitbucketUsername) String() string
type Connector ¶
type Connector interface {
// BrowseRepository opens this repository in the associated application, typically the browser.
BrowseRepository(runner subshelldomain.Runner) error
// CreateProposal creates a proposal at the forge.
CreateProposal(CreateProposalArgs) error
// DefaultProposalMessage provides the text that the form for creating new proposals
// on the respective forge type is prepopulated with.
DefaultProposalMessage(proposal ProposalData) string
// ProposalReference provides a forge-specific textual reference for the given proposal
// that can be used in proposal breadcrumb lists.
ProposalReference(proposal ProposalData) string
}
Connector describes the capabilities that all connectors can perform on forges.
type CreateProposalArgs ¶
type CreateProposalArgs struct {
Branch gitdomain.LocalBranchName
FrontendRunner subshelldomain.Runner
Interactive clidomain.Interactive
MainBranch gitdomain.LocalBranchName
ParentBranch gitdomain.LocalBranchName
ProposalBody Option[gitdomain.ProposalBody]
ProposalTitle Option[gitdomain.ProposalTitle]
}
type CredentialVerifier ¶
type CredentialVerifier interface {
// VerifyConnection checks whether this connector can make successful requests to the forge.
VerifyCredentials() VerifyCredentialsResult
}
CredentialVerifier describes capabilities to verify credentials.
type DetectedForgeType ¶
type DetectedForgeType ForgeType
DetectedForgeType is the forge type that actually exists. Its the one the user has configured, or if that is "auto", the automatically detected forge type.
func (DetectedForgeType) ForgeType ¶
func (self DetectedForgeType) ForgeType() ForgeType
ForgeType converts this value into a ForgeType.
type ForgeType ¶
type ForgeType string
ForgeType defines legal values for the "git-town.forge-type" config setting.
const ( // keep-sorted start ForgeTypeAzuredevops ForgeType = "azuredevops" ForgeTypeBitbucket ForgeType = "bitbucket" ForgeTypeBitbucketDatacenter ForgeType = "bitbucket-datacenter" ForgeTypeForgejo ForgeType = "forgejo" ForgeTypeGitea ForgeType = "gitea" ForgeTypeGithub ForgeType = "github" ForgeTypeGitlab ForgeType = "gitlab" )
func (ForgeType) Detected ¶
func (self ForgeType) Detected() DetectedForgeType
Detected converts this value into a DetectedForgeType.
type ForgejoToken ¶
ForgejoToken is a bearer token to use with the Forgejo API.
func (ForgejoToken) String ¶
func (self ForgejoToken) String() string
type GiteaToken ¶
GiteaToken is a bearer token to use with the Gitea API.
func (GiteaToken) String ¶
func (self GiteaToken) String() string
type GithubConnectorType ¶
type GithubConnectorType string
GithubConnectorType describes the various ways in which Git Town can connect to the GitHub API.
const ( GithubConnectorTypeAPI GithubConnectorType = "api" // connect to the GitHub API using Git Town's built-in API connector GithubConnectorTypeGh GithubConnectorType = "gh" // connect to the GitHub API by calling GitHub's "gh" tool )
func GithubConnectorTypes ¶
func GithubConnectorTypes() []GithubConnectorType
GithubConnectorTypes provides all possible types that the GithubConnectorTypes enum can have.
func (GithubConnectorType) String ¶
func (self GithubConnectorType) String() string
type GithubToken ¶
GithubToken is a bearer token to use with the GitHub API.
func (GithubToken) String ¶
func (self GithubToken) String() string
type GitlabConnectorType ¶
type GitlabConnectorType string
GitlabConnectorType describes the various ways in which Git Town can connect to the GitLab API.
const ( GitlabConnectorTypeAPI GitlabConnectorType = "api" // connect to the GitLab API using Git Town's built-in API connector GitlabConnectorTypeGlab GitlabConnectorType = "glab" // connect to the GitLab API by calling GitLab's "glab" tool )
func GitlabConnectorTypes ¶
func GitlabConnectorTypes() []GitlabConnectorType
GitlabConnectorTypes provides all possible types that the GitlabConnectorTypes enum can have.
func (GitlabConnectorType) String ¶
func (self GitlabConnectorType) String() string
type GitlabToken ¶
GitlabToken is a bearer token to use with the GitLab API.
func (GitlabToken) String ¶
func (self GitlabToken) String() string
type HostedRepoInfo ¶
type HostedRepoInfo struct {
// hostname of the server that hosts the repo
Hostname string
// the Organization within the forge that owns the repo
Organization string
// name of the repo on the server
Repository string
}
HostedRepoInfo provides information about a repository hosted at a forge.
func (HostedRepoInfo) HostnameWithStandardPort ¶
func (self HostedRepoInfo) HostnameWithStandardPort() string
type Proposal ¶
type Proposal struct {
Data ProposalInterface
ForgeType ForgeType
}
Proposal is a wrapper type that makes the Proposal interface serializable to and from JSON.
func (Proposal) MarshalJSON ¶
func (*Proposal) UnmarshalJSON ¶
UnmarshalJSON is used when de-serializing a Proposal from JSON.
type ProposalBodyUpdater ¶
type ProposalBodyUpdater interface {
// Updates the body (description) of the given proposal to the given value.
UpdateProposalBody(proposal ProposalInterface, newBody gitdomain.ProposalBody) error
}
ProposalBodyUpdater describes methods that connectors need to implement to enable Git Town to update proposals at the active forge.
type ProposalData ¶
type ProposalData struct {
Active bool // whether the proposal is open
Body Option[gitdomain.ProposalBody]
MergeWithAPI bool
Number ProposalNumber
Source gitdomain.LocalBranchName
Target gitdomain.LocalBranchName
Title gitdomain.ProposalTitle
URL string
}
func (ProposalData) Data ¶
func (self ProposalData) Data() ProposalData
type ProposalFinder ¶
type ProposalFinder interface {
// Loads details about the proposal for the given branch into the given target branch.
FindProposal(branch, target gitdomain.LocalBranchName) (Option[Proposal], error)
}
ProposalFinder describes methods that connectors need to implement to enable Git Town to find proposals at the active forge.
type ProposalInterface ¶
type ProposalInterface interface {
Data() ProposalData
}
ProposalInterface provides information about a change request on a forge. Alternative names are "pull request" or "merge request".
type ProposalMerger ¶
type ProposalMerger interface {
// Merges the proposal with the given number.
// When a commit message is given, it is used as the squash commit message;
// otherwise the forge determines the commit message.
SquashMergeProposal(number ProposalNumber, message Option[gitdomain.CommitMessage]) error
}
ProposalMerger describes methods that connectors need to implement to enable Git Town to merge for proposals at the active forge.
type ProposalNumber ¶
type ProposalNumber int
ProposalNumber is a number (ID) of a proposal.
Example: https://github.com/git-town/git-town/pull/5977 has proposal number 5977.
func NewProposalNumberFromFloat64 ¶
func NewProposalNumberFromFloat64(number float64) ProposalNumber
func (ProposalNumber) Int ¶
func (self ProposalNumber) Int() int
func (ProposalNumber) Int64 ¶
func (self ProposalNumber) Int64() int64
func (ProposalNumber) String ¶
func (self ProposalNumber) String() string
type ProposalSearcher ¶
type ProposalSearcher interface {
// SearchProposals finds all active proposals that have the given branch as its source branch.
SearchProposals(branch gitdomain.LocalBranchName) ([]Proposal, error)
}
ProposalSearcher describes methods that connectors need to implement to enable Git Town to search for proposals at the active forge.
type ProposalSourceUpdater ¶
type ProposalSourceUpdater interface {
// Updates the source branch of the proposal with the given number.
UpdateProposalSource(proposal ProposalInterface, newSource gitdomain.LocalBranchName) error
}
ProposalSourceUpdater describes methods that connectors need to implement to enable Git Town to update the source branch of proposals at the active forge.
type ProposalTargetUpdater ¶
type ProposalTargetUpdater interface {
// Updates the target branch of the proposal with the given number.
UpdateProposalTarget(proposal ProposalInterface, newTarget gitdomain.LocalBranchName) error
}
type VerifyCredentialsResult ¶
Source Files
¶
- api_cache.go
- bitbucket_api_token.go
- bitbucket_username.go
- connector.go
- detected_forge_type.go
- doc.go
- forge_type.go
- forgejo_token.go
- gitea_token.go
- github_connector_type.go
- github_token.go
- gitlab_connector_type.go
- gitlab_token.go
- hosted_repo_info.go
- proposal.go
- proposal_data.go
- proposal_interface.go
- proposal_number.go
- proposal_reference.go
- unsupported_service_error.go