Documentation ¶
Index ¶
- func ClearCurrentBranchCache()
- func CommentOutSquashCommitMessage(prefix string)
- func DoesBranchHaveUnmergedCommits(branchName string) bool
- func EnsureBranchInSync(branchName, errorMessageSuffix string)
- func EnsureDoesNotHaveBranch(branchName string)
- func EnsureDoesNotHaveConflicts()
- func EnsureDoesNotHaveOpenChanges(message string)
- func EnsureHasBranch(branchName string)
- func EnsureIsNotMainBranch(branchName, errorMessage string)
- func EnsureIsNotPerennialBranch(branchName, errorMessage string)
- func EnsureIsPerennialBranch(branchName, errorMessage string)
- func EnsureVersionRequirementSatisfied()
- func GetBranchSha(branchName string) string
- func GetCurrentBranchName() string
- func GetCurrentSha() string
- func GetExpectedPreviouslyCheckedOutBranch(initialPreviouslyCheckedOutBranch, initialBranch string) string
- func GetLastCommitMessage() string
- func GetLocalAuthor() string
- func GetLocalBranches() (result []string)
- func GetLocalBranchesWithDeletedTrackingBranches() (result []string)
- func GetLocalBranchesWithMainBranchFirst() (result []string)
- func GetLocalBranchesWithoutMain() (result []string)
- func GetPreviouslyCheckedOutBranch() string
- func GetPrintableBranchTree(branchName string) (result string)
- func GetPrintableMainBranch() string
- func GetPrintableNewBranchPushFlag() string
- func GetPrintableOfflineFlag() string
- func GetPrintablePerennialBranchTrees() string
- func GetPrintablePerennialBranches() string
- func GetRootDirectory() string
- func GetTrackingBranchName(branchName string) string
- func HasBranch(branchName string) bool
- func HasConflicts() bool
- func HasLocalBranch(branchName string) bool
- func HasOpenChanges() bool
- func HasRemote(name string) bool
- func HasShippableChanges(branchName string) bool
- func HasTrackingBranch(branchName string) bool
- func IsBranchInSync(branchName string) bool
- func IsMergeInProgress() bool
- func IsRebaseInProgress() bool
- func IsRepository() bool
- func ShouldBranchBePushed(branchName string) bool
- func UpdateCurrentBranchCache(branchName string)
- func ValidateIsRepository() error
- type Configuration
- func (c *Configuration) AddGitAlias(command string) *command.Result
- func (c *Configuration) AddToPerennialBranches(branchNames ...string)
- func (c *Configuration) DeleteParentBranch(branchName string)
- func (c *Configuration) EnsureIsFeatureBranch(branchName, errorSuffix string)
- func (c *Configuration) GetAncestorBranches(branchName string) (result []string)
- func (c *Configuration) GetChildBranches(branchName string) (result []string)
- func (c *Configuration) GetCodeHostingDriverName() string
- func (c *Configuration) GetCodeHostingOriginHostname() string
- func (c *Configuration) GetGitAlias(command string) string
- func (c *Configuration) GetGitHubToken() string
- func (c *Configuration) GetMainBranch() string
- func (c *Configuration) GetParentBranch(branchName string) string
- func (c *Configuration) GetParentBranchMap() map[string]string
- func (c *Configuration) GetPerennialBranches() []string
- func (c *Configuration) GetPullBranchStrategy() string
- func (c *Configuration) GetRemoteOriginURL() string
- func (c *Configuration) GetURLHostname(url string) string
- func (c *Configuration) GetURLRepositoryName(url string) string
- func (c *Configuration) HasParentBranch(branchName string) bool
- func (c *Configuration) IsAncestorBranch(branchName, ancestorBranchName string) bool
- func (c *Configuration) IsFeatureBranch(branchName string) bool
- func (c *Configuration) IsMainBranch(branchName string) bool
- func (c *Configuration) IsOffline() bool
- func (c *Configuration) IsPerennialBranch(branchName string) bool
- func (c *Configuration) RemoveFromPerennialBranches(branchName string)
- func (c *Configuration) RemoveGitAlias(command string) *command.Result
- func (c *Configuration) RemoveLocalGitConfiguration()
- func (c *Configuration) RemoveOutdatedConfiguration()
- func (c *Configuration) SetMainBranch(branchName string) *command.Result
- func (c *Configuration) SetNewBranchPush(value bool, global bool) *command.Result
- func (c *Configuration) SetOffline(value bool) *command.Result
- func (c *Configuration) SetParentBranch(branchName, parentBranchName string) *command.Result
- func (c *Configuration) SetPerennialBranches(branchNames []string) *command.Result
- func (c *Configuration) SetPullBranchStrategy(strategy string) *command.Result
- func (c *Configuration) ShouldNewBranchPush() bool
- func (c *Configuration) ShouldNewBranchPushGlobal() bool
- func (c *Configuration) ShouldSyncUpstream() bool
- func (c *Configuration) ValidateIsOnline() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearCurrentBranchCache ¶
func ClearCurrentBranchCache()
ClearCurrentBranchCache clears the cache of the current branch. This should be called when a rebase fails
func CommentOutSquashCommitMessage ¶
func CommentOutSquashCommitMessage(prefix string)
CommentOutSquashCommitMessage comments out the message for the current squash merge Adds the given prefix with the newline if provided
func DoesBranchHaveUnmergedCommits ¶
DoesBranchHaveUnmergedCommits returns whether the branch with the given name contains commits that are not merged into the main branch
func EnsureBranchInSync ¶
func EnsureBranchInSync(branchName, errorMessageSuffix string)
EnsureBranchInSync enforces that a branch with the given name is in sync with its tracking branch
func EnsureDoesNotHaveBranch ¶
func EnsureDoesNotHaveBranch(branchName string)
EnsureDoesNotHaveBranch enforces that a branch with the given name does not exist
func EnsureDoesNotHaveConflicts ¶
func EnsureDoesNotHaveConflicts()
EnsureDoesNotHaveConflicts asserts that the workspace has no unresolved merge conflicts.
func EnsureDoesNotHaveOpenChanges ¶
func EnsureDoesNotHaveOpenChanges(message string)
EnsureDoesNotHaveOpenChanges assets that the workspace has no open changes
func EnsureHasBranch ¶
func EnsureHasBranch(branchName string)
EnsureHasBranch enforces that a branch with the given name exists
func EnsureIsNotMainBranch ¶
func EnsureIsNotMainBranch(branchName, errorMessage string)
EnsureIsNotMainBranch enforces that a branch with the given name is not the main branch
func EnsureIsNotPerennialBranch ¶
func EnsureIsNotPerennialBranch(branchName, errorMessage string)
EnsureIsNotPerennialBranch enforces that a branch with the given name is not a perennial branch
func EnsureIsPerennialBranch ¶
func EnsureIsPerennialBranch(branchName, errorMessage string)
EnsureIsPerennialBranch enforces that a branch with the given name is a perennial branch
func EnsureVersionRequirementSatisfied ¶
func EnsureVersionRequirementSatisfied()
EnsureVersionRequirementSatisfied asserts that Git is the needed version or higher
func GetBranchSha ¶
GetBranchSha returns the SHA1 of the latest commit on the branch with the given name.
func GetCurrentBranchName ¶
func GetCurrentBranchName() string
GetCurrentBranchName returns the name of the currently checked out branch
func GetCurrentSha ¶
func GetCurrentSha() string
GetCurrentSha returns the SHA of the currently checked out commit.
func GetExpectedPreviouslyCheckedOutBranch ¶
func GetExpectedPreviouslyCheckedOutBranch(initialPreviouslyCheckedOutBranch, initialBranch string) string
GetExpectedPreviouslyCheckedOutBranch returns what is the expected previously checked out branch given the inputs
func GetLastCommitMessage ¶
func GetLastCommitMessage() string
GetLastCommitMessage returns the commit message for the last commit
func GetLocalAuthor ¶
func GetLocalAuthor() string
GetLocalAuthor returns the locally Git configured user
func GetLocalBranches ¶
func GetLocalBranches() (result []string)
GetLocalBranches returns the names of all branches in the local repository, ordered alphabetically
func GetLocalBranchesWithDeletedTrackingBranches ¶
func GetLocalBranchesWithDeletedTrackingBranches() (result []string)
GetLocalBranchesWithDeletedTrackingBranches returns the names of all branches whose remote tracking branches have been deleted
func GetLocalBranchesWithMainBranchFirst ¶
func GetLocalBranchesWithMainBranchFirst() (result []string)
GetLocalBranchesWithMainBranchFirst returns the names of all branches that exist in the local repository, ordered to have the name of the main branch first, then the names of the branches, ordered alphabetically
func GetLocalBranchesWithoutMain ¶
func GetLocalBranchesWithoutMain() (result []string)
GetLocalBranchesWithoutMain returns the names of all branches in the local repository, ordered alphabetically without the main branch
func GetPreviouslyCheckedOutBranch ¶
func GetPreviouslyCheckedOutBranch() string
GetPreviouslyCheckedOutBranch returns the name of the previously checked out branch
func GetPrintableBranchTree ¶
GetPrintableBranchTree returns a user printable branch tree
func GetPrintableMainBranch ¶
func GetPrintableMainBranch() string
GetPrintableMainBranch returns a user printable main branch
func GetPrintableNewBranchPushFlag ¶
func GetPrintableNewBranchPushFlag() string
GetPrintableNewBranchPushFlag returns a user printable new branch push flag
func GetPrintableOfflineFlag ¶
func GetPrintableOfflineFlag() string
GetPrintableOfflineFlag returns a user printable offline flag
func GetPrintablePerennialBranchTrees ¶
func GetPrintablePerennialBranchTrees() string
GetPrintablePerennialBranchTrees returns a user printable list of perennial branches trees
func GetPrintablePerennialBranches ¶
func GetPrintablePerennialBranches() string
GetPrintablePerennialBranches returns a user printable list of perennial branches
func GetRootDirectory ¶
func GetRootDirectory() string
GetRootDirectory returns the path of the rood directory of the current repository, i.e. the directory that contains the ".git" folder.
func GetTrackingBranchName ¶
GetTrackingBranchName returns the name of the remote branch that corresponds to the local branch with the given name
func HasBranch ¶
HasBranch returns whether the repository contains a branch with the given name. The branch does not have to be present on the local repository.
func HasConflicts ¶
func HasConflicts() bool
HasConflicts returns whether the local repository currently has unresolved merge conflicts.
func HasLocalBranch ¶
HasLocalBranch returns whether the local repository contains a branch with the given name.
func HasOpenChanges ¶
func HasOpenChanges() bool
HasOpenChanges returns whether the local repository contains uncommitted changes.
func HasRemote ¶
HasRemote returns whether the current repository contains a Git remote with the given name.
func HasShippableChanges ¶
HasShippableChanges returns whether the supplied branch has an changes not currently on the main branchName
func HasTrackingBranch ¶
HasTrackingBranch returns whether the local branch with the given name has a tracking branch.
func IsBranchInSync ¶
IsBranchInSync returns whether the branch with the given name is in sync with its tracking branch
func IsMergeInProgress ¶
func IsMergeInProgress() bool
IsMergeInProgress returns whether the local repository is in the middle of an unfinished merge process.
func IsRebaseInProgress ¶
func IsRebaseInProgress() bool
IsRebaseInProgress returns whether the local repository is in the middle of an unfinished rebase process.
func IsRepository ¶
func IsRepository() bool
IsRepository returns whether or not the current directory is in a repository
func ShouldBranchBePushed ¶
ShouldBranchBePushed returns whether the local branch with the given name contains commits that have not been pushed to the remote.
func UpdateCurrentBranchCache ¶
func UpdateCurrentBranchCache(branchName string)
UpdateCurrentBranchCache clears the cache of the current branch. This should be called when a new branch is checked out
func ValidateIsRepository ¶
func ValidateIsRepository() error
ValidateIsRepository asserts that the current directory is in a repository
Types ¶
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
Configuration manages the Git Town configuration stored in Git metadata in the given local repo and the global Git configuration. This class manages which config values are stored in local vs global settings.
func Config ¶
func Config() *Configuration
Config provides the current configuration. This is used in the Git Town business logic, which runs in the current directory. The configuration is lazy-loaded this way to allow using some Git Town commands outside of Git repositories.
func NewConfiguration ¶
func NewConfiguration(dir string) *Configuration
NewConfiguration provides a Configuration instance reflecting the configuration values in the given directory.
func (*Configuration) AddGitAlias ¶
func (c *Configuration) AddGitAlias(command string) *command.Result
AddGitAlias sets the given Git alias.
func (*Configuration) AddToPerennialBranches ¶
func (c *Configuration) AddToPerennialBranches(branchNames ...string)
AddToPerennialBranches registers the given branch names as perennial branches. The branches must exist.
func (*Configuration) DeleteParentBranch ¶
func (c *Configuration) DeleteParentBranch(branchName string)
DeleteParentBranch removes the parent branch entry for the given branch from the Git configuration.
func (*Configuration) EnsureIsFeatureBranch ¶
func (c *Configuration) EnsureIsFeatureBranch(branchName, errorSuffix string)
EnsureIsFeatureBranch asserts that the given branch is a feature branch.
func (*Configuration) GetAncestorBranches ¶
func (c *Configuration) GetAncestorBranches(branchName string) (result []string)
GetAncestorBranches returns the names of all parent branches for the given branch, This information is read from the cache in the Git config, so might be out of date when the branch hierarchy has been modified.
func (*Configuration) GetChildBranches ¶
func (c *Configuration) GetChildBranches(branchName string) (result []string)
GetChildBranches returns the names of all branches for which the given branch is a parent.
func (*Configuration) GetCodeHostingDriverName ¶
func (c *Configuration) GetCodeHostingDriverName() string
GetCodeHostingDriverName provides the name of the code hosting driver to use.
func (*Configuration) GetCodeHostingOriginHostname ¶
func (c *Configuration) GetCodeHostingOriginHostname() string
GetCodeHostingOriginHostname provides the host name of the code hosting server.
func (*Configuration) GetGitAlias ¶
func (c *Configuration) GetGitAlias(command string) string
GetGitAlias provides the currently set alias for the given Git Town command.
func (*Configuration) GetGitHubToken ¶
func (c *Configuration) GetGitHubToken() string
GetGitHubToken provides the content of the GitHub API token stored in the local or global Git Town configuration.
func (*Configuration) GetMainBranch ¶
func (c *Configuration) GetMainBranch() string
GetMainBranch returns the name of the main branch.
func (*Configuration) GetParentBranch ¶
func (c *Configuration) GetParentBranch(branchName string) string
GetParentBranch returns the name of the parent branch of the given branch.
func (*Configuration) GetParentBranchMap ¶
func (c *Configuration) GetParentBranchMap() map[string]string
GetParentBranchMap returns a map from branch name to its parent branch
func (*Configuration) GetPerennialBranches ¶
func (c *Configuration) GetPerennialBranches() []string
GetPerennialBranches returns all branches that are marked as perennial.
func (*Configuration) GetPullBranchStrategy ¶
func (c *Configuration) GetPullBranchStrategy() string
GetPullBranchStrategy returns the currently configured pull branch strategy.
func (*Configuration) GetRemoteOriginURL ¶
func (c *Configuration) GetRemoteOriginURL() string
GetRemoteOriginURL returns the URL for the "origin" remote. In tests this value can be stubbed.
func (*Configuration) GetURLHostname ¶
func (c *Configuration) GetURLHostname(url string) string
GetURLHostname returns the hostname contained within the given Git URL.
func (*Configuration) GetURLRepositoryName ¶
func (c *Configuration) GetURLRepositoryName(url string) string
GetURLRepositoryName returns the repository name contains within the given Git URL.
func (*Configuration) HasParentBranch ¶
func (c *Configuration) HasParentBranch(branchName string) bool
HasParentBranch returns whether or not the given branch has a parent
func (*Configuration) IsAncestorBranch ¶
func (c *Configuration) IsAncestorBranch(branchName, ancestorBranchName string) bool
IsAncestorBranch indicates whether the given branch is an ancestor of the other given branch.
func (*Configuration) IsFeatureBranch ¶
func (c *Configuration) IsFeatureBranch(branchName string) bool
IsFeatureBranch indicates whether the branch with the given name is a feature branch.
func (*Configuration) IsMainBranch ¶
func (c *Configuration) IsMainBranch(branchName string) bool
IsMainBranch indicates whether the branch with the given name is the main branch of the repository.
func (*Configuration) IsOffline ¶
func (c *Configuration) IsOffline() bool
IsOffline indicates whether Git Town is currently in offline mode
func (*Configuration) IsPerennialBranch ¶
func (c *Configuration) IsPerennialBranch(branchName string) bool
IsPerennialBranch indicates whether the branch with the given name is a perennial branch.
func (*Configuration) RemoveFromPerennialBranches ¶
func (c *Configuration) RemoveFromPerennialBranches(branchName string)
RemoveFromPerennialBranches removes the given branch as a perennial branch
func (*Configuration) RemoveGitAlias ¶
func (c *Configuration) RemoveGitAlias(command string) *command.Result
RemoveGitAlias removes the given Git alias.
func (*Configuration) RemoveLocalGitConfiguration ¶
func (c *Configuration) RemoveLocalGitConfiguration()
RemoveLocalGitConfiguration removes all Git Town configuration
func (*Configuration) RemoveOutdatedConfiguration ¶
func (c *Configuration) RemoveOutdatedConfiguration()
RemoveOutdatedConfiguration removes outdated Git Town configuration
func (*Configuration) SetMainBranch ¶
func (c *Configuration) SetMainBranch(branchName string) *command.Result
SetMainBranch marks the given branch as the main branch in the Git Town configuration.
func (*Configuration) SetNewBranchPush ¶
func (c *Configuration) SetNewBranchPush(value bool, global bool) *command.Result
SetNewBranchPush updates whether the current repository is configured to push freshly created branches up to the origin remote.
func (*Configuration) SetOffline ¶
func (c *Configuration) SetOffline(value bool) *command.Result
SetOffline updates whether Git Town is in offline mode
func (*Configuration) SetParentBranch ¶
func (c *Configuration) SetParentBranch(branchName, parentBranchName string) *command.Result
SetParentBranch marks the given branch as the direct parent of the other given branch in the Git Town configuration.
func (*Configuration) SetPerennialBranches ¶
func (c *Configuration) SetPerennialBranches(branchNames []string) *command.Result
SetPerennialBranches marks the given branches as perennial branches
func (*Configuration) SetPullBranchStrategy ¶
func (c *Configuration) SetPullBranchStrategy(strategy string) *command.Result
SetPullBranchStrategy updates the configured pull branch strategy.
func (*Configuration) ShouldNewBranchPush ¶
func (c *Configuration) ShouldNewBranchPush() bool
ShouldNewBranchPush indicates whether the current repository is configured to push freshly created branches up to the origin remote.
func (*Configuration) ShouldNewBranchPushGlobal ¶
func (c *Configuration) ShouldNewBranchPushGlobal() bool
ShouldNewBranchPushGlobal indictes whether the global configuration requires to push freshly created branches up to the origin remote.
func (*Configuration) ShouldSyncUpstream ¶
func (c *Configuration) ShouldSyncUpstream() bool
ShouldSyncUpstream indicates whether this repo should sync with its upstream.
func (*Configuration) ValidateIsOnline ¶
func (c *Configuration) ValidateIsOnline() error
ValidateIsOnline asserts that Git Town is not in offline mode