forgedomain

package
v24.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package forgedomain provides the domain model for forges.

Index

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

func ParseForgeType(name stringss.Trimmed, source string) (Option[ForgeType], error)

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

type BitbucketAPIToken stringss.Trimmed

func (BitbucketAPIToken) String

func (self BitbucketAPIToken) String() string

type BitbucketCloudProposalData

type BitbucketCloudProposalData struct {
	ProposalData
	CloseSourceBranch bool
	Draft             bool
}

func (BitbucketCloudProposalData) Data

type BitbucketUsername

type BitbucketUsername stringss.Trimmed

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.

func (ForgeType) String

func (self ForgeType) String() string

type ForgejoToken

type ForgejoToken stringss.Trimmed

ForgejoToken is a bearer token to use with the Forgejo API.

func (ForgejoToken) String

func (self ForgejoToken) String() string

type GiteaToken

type GiteaToken stringss.Trimmed

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

type GithubToken stringss.Trimmed

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

type GitlabToken stringss.Trimmed

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 (self Proposal) MarshalJSON() ([]byte, error)

func (*Proposal) UnmarshalJSON

func (self *Proposal) UnmarshalJSON(b []byte) error

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 Result

type Result any

type VerifyCredentialsResult

type VerifyCredentialsResult struct {
	AuthenticatedUser   Option[string] // the authenticated username
	AuthenticationError error          // error while verifying to verify authentication
	AuthorizationError  error          // error while verifying authorization, nil == user is authenticated
}

Jump to

Keyboard shortcuts

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