Documentation
¶
Overview ¶
Package gitdomain defines basic concepts from the domain of Git: branches, remotes, commit SHAs, etc.
Index ¶
- func AuthorOptFromString(name string) Option[Author]
- func GitUserNameOptFromString(value stringss.Trimmed) Option[GitUserName]
- func GitUserNameOptFromStringOpt(valueOpt Option[string]) Option[GitUserName]
- func LocalBranchNameOpt(id stringss.Trimmed) Option[LocalBranchName]
- func NewProposalBodyOpt(text string) Option[ProposalBody]
- func NewRemote(id stringss.Trimmed) Option[Remote]
- func ParseGitUserEmail(value stringss.Trimmed) Option[GitUserEmail]
- func ParseGitUserEmailOpt(valueOpt Option[string]) Option[GitUserEmail]
- func RemoteBranchNameOpt(id string) Option[RemoteBranchName]
- type Author
- type BranchData
- type BranchInfo
- func (self BranchInfo) GetLocalOrRemoteName() BranchName
- func (self BranchInfo) GetLocalOrRemoteNameAsLocalName() LocalBranchName
- func (self BranchInfo) GetLocalOrRemoteSHA() SHA
- func (self BranchInfo) GetRemote() (bool, RemoteBranchName, SHA)
- func (self BranchInfo) GetSHAs() BranchInfoSHAs
- func (self BranchInfo) HasOnlyLocalBranch() bool
- func (self BranchInfo) HasOnlyRemoteBranch() bool
- func (self BranchInfo) HasTrackingBranch() bool
- func (self BranchInfo) IsLocalOnlyBranch() (bool, LocalBranchName)
- func (self BranchInfo) LocalBranchName() LocalBranchName
- func (self BranchInfo) LocalName() Option[LocalBranchName]
- func (self BranchInfo) LocalSHA() Option[SHA]
- func (self BranchInfo) OmniBranch() Option[BranchData]
- func (self BranchInfo) String() string
- type BranchInfoSHAs
- type BranchInfos
- func (self BranchInfos) BranchIsActiveInAnotherWorktree(branch LocalBranchName) bool
- func (self BranchInfos) BranchesDeletedAtRemote() LocalBranchNames
- func (self BranchInfos) BranchesInOtherWorktrees() LocalBranchNames
- func (self BranchInfos) FindByLocalName(branchName LocalBranchName) OptionalMutable[BranchInfo]
- func (self BranchInfos) FindByRemoteName(remoteBranch RemoteBranchName) OptionalMutable[BranchInfo]
- func (self BranchInfos) FindLocalOrRemote(branchName LocalBranchName) OptionalMutable[BranchInfo]
- func (self BranchInfos) FindMatchingRecord(other BranchInfo) OptionalMutable[BranchInfo]
- func (self BranchInfos) FindRemoteNameMatchingLocal(localBranch LocalBranchName) OptionalMutable[BranchInfo]
- func (self BranchInfos) HasBranch(branch LocalBranchName) bool
- func (self BranchInfos) HasLocalBranch(branch LocalBranchName) bool
- func (self BranchInfos) HasLocalBranches(branches LocalBranchNames) bool
- func (self BranchInfos) HasMatchingTrackingBranchFor(localBranch LocalBranchName) bool
- func (self BranchInfos) LocalBranches() BranchInfos
- func (self BranchInfos) LocalBranchesWithDeletedTrackingBranches() BranchInfos
- func (self BranchInfos) NamesAllBranches() LocalBranchNames
- func (self BranchInfos) NamesLocalBranches() LocalBranchNames
- func (self BranchInfos) Remove(branchName LocalBranchName) BranchInfos
- func (self BranchInfos) Select(names ...LocalBranchName) (result BranchInfos, nonExisting LocalBranchNames)
- func (self BranchInfos) String() string
- func (self BranchInfos) UpdateLocalSHA(branch LocalBranchName, sha SHA) error
- type BranchName
- type BranchNames
- type BranchesSnapshot
- type Commit
- type CommitMessage
- type CommitMessageFile
- type CommitMessageParts
- type CommitMessages
- type CommitTitle
- type Commits
- type ConflictResolution
- type GitUserEmail
- type GitUserName
- type LocalBranchName
- type LocalBranchNames
- func (self LocalBranchNames) AppendAllMissing(others LocalBranchNames) LocalBranchNames
- func (self LocalBranchNames) BranchNames() []BranchName
- func (self LocalBranchNames) Contains(branch LocalBranchName) bool
- func (self LocalBranchNames) Hoist(branches ...LocalBranchName) LocalBranchNames
- func (self LocalBranchNames) Join(sep string) string
- func (self LocalBranchNames) Remove(toRemove ...LocalBranchName) LocalBranchNames
- func (self LocalBranchNames) String() string
- func (self LocalBranchNames) Strings() []string
- type Location
- type ProposalBody
- type ProposalBodyFile
- type ProposalTitle
- type Remote
- type RemoteBranchName
- type RemoteBranchNames
- type Remotes
- type RepoRootDir
- type RepoStatus
- type SHA
- type SHAs
- type StashSize
- type SyncStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthorOptFromString ¶ added in v23.0.2
func GitUserNameOptFromString ¶ added in v23.0.2
func GitUserNameOptFromString(value stringss.Trimmed) Option[GitUserName]
func GitUserNameOptFromStringOpt ¶ added in v23.0.2
func GitUserNameOptFromStringOpt(valueOpt Option[string]) Option[GitUserName]
func LocalBranchNameOpt ¶ added in v23.0.2
func LocalBranchNameOpt(id stringss.Trimmed) Option[LocalBranchName]
func NewProposalBodyOpt ¶
func NewProposalBodyOpt(text string) Option[ProposalBody]
func ParseGitUserEmail ¶
func ParseGitUserEmail(value stringss.Trimmed) Option[GitUserEmail]
func ParseGitUserEmailOpt ¶
func ParseGitUserEmailOpt(valueOpt Option[string]) Option[GitUserEmail]
func RemoteBranchNameOpt ¶ added in v23.0.2
func RemoteBranchNameOpt(id string) Option[RemoteBranchName]
Types ¶
type BranchData ¶
type BranchData struct {
Name LocalBranchName
SHA SHA
}
type BranchInfo ¶
type BranchInfo struct {
Local Option[BranchData]
// RemoteName contains the fully qualified name of the tracking branch, i.e. "origin/foo".
RemoteName Option[RemoteBranchName]
// RemoteSHA contains the SHA of the tracking branch before Git Town ran.
RemoteSHA Option[SHA]
// SyncStatus of the branch.
SyncStatus SyncStatus
}
BranchInfo describes the sync status of a branch in relation to its tracking branch.
func (BranchInfo) GetLocalOrRemoteName ¶
func (self BranchInfo) GetLocalOrRemoteName() BranchName
func (BranchInfo) GetLocalOrRemoteNameAsLocalName ¶
func (self BranchInfo) GetLocalOrRemoteNameAsLocalName() LocalBranchName
func (BranchInfo) GetLocalOrRemoteSHA ¶
func (self BranchInfo) GetLocalOrRemoteSHA() SHA
func (BranchInfo) GetRemote ¶
func (self BranchInfo) GetRemote() (bool, RemoteBranchName, SHA)
GetRemote provides both the name and SHA of the remote branch.
func (BranchInfo) GetSHAs ¶
func (self BranchInfo) GetSHAs() BranchInfoSHAs
GetSHAs provides the SHAs of the local and remote branch.
func (BranchInfo) HasOnlyLocalBranch ¶
func (self BranchInfo) HasOnlyLocalBranch() bool
func (BranchInfo) HasOnlyRemoteBranch ¶
func (self BranchInfo) HasOnlyRemoteBranch() bool
func (BranchInfo) HasTrackingBranch ¶
func (self BranchInfo) HasTrackingBranch() bool
func (BranchInfo) IsLocalOnlyBranch ¶
func (self BranchInfo) IsLocalOnlyBranch() (bool, LocalBranchName)
func (BranchInfo) LocalBranchName ¶
func (self BranchInfo) LocalBranchName() LocalBranchName
LocalBranchName provides the name of this branch as a local branch, independent of whether this branch is local or not.
func (BranchInfo) LocalName ¶
func (self BranchInfo) LocalName() Option[LocalBranchName]
func (BranchInfo) LocalSHA ¶
func (self BranchInfo) LocalSHA() Option[SHA]
func (BranchInfo) OmniBranch ¶
func (self BranchInfo) OmniBranch() Option[BranchData]
OmniBranch indicates whether the branch described by this BranchInfo is omni and provides all relevant data around this scenario. An omni branch has the same SHA locally and remotely.
func (BranchInfo) String ¶
func (self BranchInfo) String() string
type BranchInfoSHAs ¶
type BranchInfos ¶
type BranchInfos []BranchInfo
BranchInfos contains the BranchInfos for all branches in a repo. Tracking branches on the origin remote don't get their own entry, they are listed in the `TrackingBranch` property of the local branch they track.
func (BranchInfos) BranchIsActiveInAnotherWorktree ¶
func (self BranchInfos) BranchIsActiveInAnotherWorktree(branch LocalBranchName) bool
func (BranchInfos) BranchesDeletedAtRemote ¶
func (self BranchInfos) BranchesDeletedAtRemote() LocalBranchNames
func (BranchInfos) BranchesInOtherWorktrees ¶
func (self BranchInfos) BranchesInOtherWorktrees() LocalBranchNames
func (BranchInfos) FindByLocalName ¶
func (self BranchInfos) FindByLocalName(branchName LocalBranchName) OptionalMutable[BranchInfo]
FindByLocalName provides the branch with the given name if one exists.
func (BranchInfos) FindByRemoteName ¶
func (self BranchInfos) FindByRemoteName(remoteBranch RemoteBranchName) OptionalMutable[BranchInfo]
FindByRemoteName provides the local branch that has the given remote branch as its tracking branch or nil if no such branch exists.
func (BranchInfos) FindLocalOrRemote ¶
func (self BranchInfos) FindLocalOrRemote(branchName LocalBranchName) OptionalMutable[BranchInfo]
func (BranchInfos) FindMatchingRecord ¶
func (self BranchInfos) FindMatchingRecord(other BranchInfo) OptionalMutable[BranchInfo]
func (BranchInfos) FindRemoteNameMatchingLocal ¶
func (self BranchInfos) FindRemoteNameMatchingLocal(localBranch LocalBranchName) OptionalMutable[BranchInfo]
FindRemoteNameMatchingLocal finds the BranchInfo with a remote name that matches the given local branch name.
func (BranchInfos) HasBranch ¶
func (self BranchInfos) HasBranch(branch LocalBranchName) bool
func (BranchInfos) HasLocalBranch ¶
func (self BranchInfos) HasLocalBranch(branch LocalBranchName) bool
HasLocalBranch indicates whether the given local branch is already known to this BranchInfos instance.
func (BranchInfos) HasLocalBranches ¶
func (self BranchInfos) HasLocalBranches(branches LocalBranchNames) bool
HasLocalBranches indicates whether this BranchInfos instance contains all the given branches.
func (BranchInfos) HasMatchingTrackingBranchFor ¶
func (self BranchInfos) HasMatchingTrackingBranchFor(localBranch LocalBranchName) bool
HasMatchingTrackingBranchFor indicates whether there is already a remote branch matching the given local branch.
func (BranchInfos) LocalBranches ¶
func (self BranchInfos) LocalBranches() BranchInfos
LocalBranches provides only the branches that exist on the local machine.
func (BranchInfos) LocalBranchesWithDeletedTrackingBranches ¶
func (self BranchInfos) LocalBranchesWithDeletedTrackingBranches() BranchInfos
LocalBranchesWithDeletedTrackingBranches provides only the branches that exist locally and have a deleted tracking branch.
func (BranchInfos) NamesAllBranches ¶
func (self BranchInfos) NamesAllBranches() LocalBranchNames
NamesAllBranches provides the local names for all branches in this BranchesSyncStatus instance.
func (BranchInfos) NamesLocalBranches ¶
func (self BranchInfos) NamesLocalBranches() LocalBranchNames
NamesLocalBranches provides the names of all local branches in this BranchesSyncStatus instance.
func (BranchInfos) Remove ¶
func (self BranchInfos) Remove(branchName LocalBranchName) BranchInfos
func (BranchInfos) Select ¶
func (self BranchInfos) Select(names ...LocalBranchName) (result BranchInfos, nonExisting LocalBranchNames)
Select provides the BranchInfos with the given names.
func (BranchInfos) String ¶
func (self BranchInfos) String() string
func (BranchInfos) UpdateLocalSHA ¶
func (self BranchInfos) UpdateLocalSHA(branch LocalBranchName, sha SHA) error
type BranchName ¶
BranchName is the name of a local or remote Git branch.
func BranchNameOrPanic ¶ added in v23.0.2
func BranchNameOrPanic(id stringss.Trimmed) BranchName
func (BranchName) IsLocal ¶
func (self BranchName) IsLocal() bool
IsLocal indicates whether the branch with this BranchName exists locally.
func (BranchName) LocalName ¶
func (self BranchName) LocalName() LocalBranchName
LocalName provides the (theoretical) local version of this branch name.
func (BranchName) Location ¶
func (self BranchName) Location() Location
func (BranchName) RefName ¶
func (self BranchName) RefName() string
RefName provides the fully qualified reference name for this branch.
func (BranchName) RemoteName ¶
func (self BranchName) RemoteName() RemoteBranchName
RemoteName provides the remote version of this branch name.
func (BranchName) String ¶
func (self BranchName) String() string
String implements the fmt.Stringer interface.
type BranchNames ¶
type BranchNames []BranchName
func (BranchNames) Join ¶
func (self BranchNames) Join(sep string) string
func (BranchNames) LocalBranchNames ¶
func (self BranchNames) LocalBranchNames() LocalBranchNames
func (BranchNames) Strings ¶
func (self BranchNames) Strings() []string
type BranchesSnapshot ¶
type BranchesSnapshot struct {
// the branch that was checked out at the time the snapshot was taken
Active Option[LocalBranchName]
// Branches is a read-only copy of the branches that exist in this repo at the time the snapshot was taken.
// Don't use these branches for business logic since businss logic might want to modify its in-memory cache of branches
// as it adds or removes branches.
Branches BranchInfos
// DetachedHead indicates whether the repo had a detached head at the time this snapshot was taken.
DetachedHead bool
}
BranchesSnapshot is a snapshot of the Git branches at a particular point in time.
func EmptyBranchesSnapshot ¶
func EmptyBranchesSnapshot() BranchesSnapshot
type Commit ¶
type Commit struct {
Message CommitMessage
SHA SHA
}
type CommitMessage ¶
CommitMessage is the entire textual messages of a Git commit.
func (CommitMessage) Parts ¶
func (self CommitMessage) Parts() CommitMessageParts
Parts separates the parts of the given commit message.
func (CommitMessage) String ¶
func (self CommitMessage) String() string
String implements the fmt.Stringer interface.
type CommitMessageFile ¶
CommitMessageFile is the name of the file from which to read the CommitMessage.
func (CommitMessageFile) ShouldReadStdin ¶
func (self CommitMessageFile) ShouldReadStdin() bool
ShouldReadStdin indicates whether the commit message should be read from STDIN.
func (CommitMessageFile) String ¶
func (self CommitMessageFile) String() string
String implements the fmt.Stringer interface.
type CommitMessageParts ¶
type CommitMessageParts struct {
Body string // the commit message text minus the first line and empty lines separating it from the rest of the message
Title CommitTitle // the first line of the commit message
}
CommitMessageParts describes the parts of a Git commit message.
type CommitMessages ¶
type CommitMessages []CommitMessage
func NewCommitMessages ¶
func NewCommitMessages(messages ...string) CommitMessages
type CommitTitle ¶
CommitTitle is the first line of a CommitMessage.
func (CommitTitle) String ¶
func (self CommitTitle) String() string
type Commits ¶
type Commits []Commit
func (Commits) ContainsSHA ¶
ContainsSHA indicates whether this commits list contains a commit with the given SHA.
func (Commits) FindByCommitMessage ¶
func (self Commits) FindByCommitMessage(message CommitMessage) Option[Commit]
func (Commits) Messages ¶
func (self Commits) Messages() CommitMessages
type ConflictResolution ¶
type ConflictResolution string
const ( ConflictResolutionOurs ConflictResolution = "ours" ConflictResolutionTheirs ConflictResolution = "theirs" )
func (ConflictResolution) GitFlag ¶
func (self ConflictResolution) GitFlag() string
func (ConflictResolution) String ¶
func (self ConflictResolution) String() string
type GitUserEmail ¶
func (GitUserEmail) String ¶
func (self GitUserEmail) String() string
type GitUserName ¶
func (GitUserName) String ¶
func (self GitUserName) String() string
type LocalBranchName ¶
LocalBranchName is the name of a local Git branch. The zero value is an empty local branch name, i.e. a local branch name that is unknown or not configured.
func LocalBranchNameOrPanic ¶ added in v23.0.2
func LocalBranchNameOrPanic(id stringss.Trimmed) LocalBranchName
func (LocalBranchName) BranchName ¶
func (self LocalBranchName) BranchName() BranchName
BranchName widens the type of this LocalBranchName to a more generic BranchName.
func (LocalBranchName) Location ¶
func (self LocalBranchName) Location() Location
Location widens the type of this LocalBranchName to a more generic Location.
func (LocalBranchName) RefName ¶
func (self LocalBranchName) RefName() string
RefName provides the fully qualified reference name for this branch.
func (LocalBranchName) String ¶
func (self LocalBranchName) String() string
String implements the fmt.Stringer interface.
type LocalBranchNames ¶
type LocalBranchNames []LocalBranchName
func NewLocalBranchNames ¶
func NewLocalBranchNames(names ...string) LocalBranchNames
func ParseLocalBranchNames ¶
func ParseLocalBranchNames(names stringss.Trimmed) LocalBranchNames
ParseLocalBranchNames constructs a LocalBranchNames instance containing the branches listed in the given space-separated string.
func (LocalBranchNames) AppendAllMissing ¶
func (self LocalBranchNames) AppendAllMissing(others LocalBranchNames) LocalBranchNames
AppendAllMissing provides a LocalBranchNames list consisting of the sum of this and elements of other list that aren't in this list.
func (LocalBranchNames) BranchNames ¶
func (self LocalBranchNames) BranchNames() []BranchName
func (LocalBranchNames) Contains ¶
func (self LocalBranchNames) Contains(branch LocalBranchName) bool
Contains indicates whether this collection contains the given branch.
func (LocalBranchNames) Hoist ¶
func (self LocalBranchNames) Hoist(branches ...LocalBranchName) LocalBranchNames
Hoist returns the given list with the given branches moved to the front, in the order they are given.
func (LocalBranchNames) Join ¶
func (self LocalBranchNames) Join(sep string) string
Join provides the names of all branches in this collection connected by the given separator.
func (LocalBranchNames) Remove ¶
func (self LocalBranchNames) Remove(toRemove ...LocalBranchName) LocalBranchNames
Remove removes the given branch names from this collection.
func (LocalBranchNames) String ¶
func (self LocalBranchNames) String() string
func (LocalBranchNames) Strings ¶
func (self LocalBranchNames) Strings() []string
Strings provides the names of all branches in this collection as strings.
type Location ¶
Location is a location within a Git repo. Examples for locations are SHA addresses of commits or branch names.
func NewLocation ¶
func (Location) IsRemoteBranchName ¶
type ProposalBody ¶
ProposalBody is the body of a proposal
func (ProposalBody) String ¶
func (self ProposalBody) String() string
String implements the fmt.Stringer interface.
type ProposalBodyFile ¶
ProposalBodyFile is the body of a proposal.
func (ProposalBodyFile) ShouldReadStdin ¶
func (self ProposalBodyFile) ShouldReadStdin() bool
ShouldReadStdin indicates whether the body should be read from STDIN.
func (ProposalBodyFile) String ¶
func (self ProposalBodyFile) String() string
String implements the fmt.Stringer interface.
type ProposalTitle ¶
ProposalTitle is the title of a proposal
func (ProposalTitle) String ¶
func (self ProposalTitle) String() string
String implements the fmt.Stringer interface.
type RemoteBranchName ¶
RemoteBranchName is the name of a remote branch, e.g. "origin/foo".
func RemoteBranchNameOrPanic ¶ added in v23.0.2
func RemoteBranchNameOrPanic(id string) RemoteBranchName
func (RemoteBranchName) BranchName ¶
func (self RemoteBranchName) BranchName() BranchName
BranchName widens the type of this RemoteBranchName to a more generic BranchName.
func (RemoteBranchName) LocalBranchName ¶
func (self RemoteBranchName) LocalBranchName() LocalBranchName
LocalBranchName provides the name of the local branch that this remote branch tracks.
func (RemoteBranchName) Parts ¶
func (self RemoteBranchName) Parts() (Remote, LocalBranchName)
func (RemoteBranchName) Remote ¶
func (self RemoteBranchName) Remote() Remote
func (RemoteBranchName) String ¶
func (self RemoteBranchName) String() string
type RemoteBranchNames ¶
type RemoteBranchNames []RemoteBranchName
type Remotes ¶
type Remotes []Remote
Remotes answers questions which Git remotes a repo has.
func NewRemotes ¶
func (Remotes) HasUpstream ¶
type RepoRootDir ¶
RepoRootDir represents the root directory of a Git repository.
func NewRepoRootDir ¶
func NewRepoRootDir(dir string) RepoRootDir
func (RepoRootDir) String ¶
func (self RepoRootDir) String() string
type RepoStatus ¶
type SHA ¶
SHA represents a Git SHA as a dedicated data type. This helps avoid stringly-typed code.
func NewSHAOrPanic ¶ added in v23.0.2
NewSHAOrPanic creates a new SHA instance with the given value. The value is verified for correctness.
func (SHA) TrimmedString ¶ added in v23.0.2
TrimmedString provides the content of this SHA as a trimmed string.
type SyncStatus ¶
type SyncStatus string
SyncStatus encodes the places a branch can exist at. This is a type-safe enum, see https://npf.io/2022/05/safer-enums.
const ( // keep-sorted start SyncStatusAhead SyncStatus = "ahead" // the branch exists locally and remotely, the local branch is ahead of the remote branch SyncStatusBehind SyncStatus = "behind" // the branch exists locally and remotely, the local branch is behind the remote branch SyncStatusDeletedAtRemote SyncStatus = "deleted at remote" // the branch was deleted on the remote SyncStatusLocalOnly SyncStatus = "local only" // the branch was created locally and hasn't been pushed to the remote yet SyncStatusNotInSync SyncStatus = "not in sync" // the branch exists locally and remotely, the local branch has different commits than the remote branch SyncStatusOtherWorktree SyncStatus = "active in another worktree" // the branch is active in another worktree and should not be synced SyncStatusRemoteOnly SyncStatus = "remote only" // the branch exists only at the remote SyncStatusUpToDate SyncStatus = "up to date" // the branch exists locally and remotely, the local branch is up to date )
func (SyncStatus) String ¶
func (self SyncStatus) String() string
Source Files
¶
- author.go
- branch_data.go
- branch_info.go
- branch_infos.go
- branch_name.go
- branch_names.go
- branches_snapshot.go
- commit.go
- commit_message.go
- commit_message_file.go
- commit_messages.go
- commit_title.go
- commits.go
- conflict_resolution.go
- doc.go
- git_user_email.go
- git_user_name.go
- local_branch_name.go
- local_branch_names.go
- location.go
- proposal_body.go
- proposal_body_file.go
- proposal_title.go
- remote.go
- remote_branch_name.go
- remote_branch_names.go
- remotes.go
- repo_root_dir.go
- repo_status.go
- sha.go
- shas.go
- stash_size.go
- sync_status.go