Documentation
¶
Index ¶
- Constants
- Variables
- func AddStackBaseBranch(title string, branch string) error
- func AddStackRefDir(dir string) (string, error)
- func AddStackRefFile(title string, stackRef StackRef) error
- func AddUpstreamRemote(upstreamURL, cloneDir string) error
- func CheckoutBranch(branch string, gr GitRunner) error
- func CheckoutNewBranch(branch string) error
- func CommitBody(sha string) (string, error)
- func Config(name string) (string, error)
- func CreateBranches(t *testing.T, branches []string)
- func CreateRefFiles(refs map[string]StackRef, title string) error
- func CurrentBranch() (string, error)
- func DeleteLocalBranch(branch string, gr GitRunner) error
- func DeleteStackRefFile(title string, stackRef StackRef) error
- func DescribeByTags() (string, error)
- func GetAllConfig(key string) ([]byte, error)
- func GetCurrentStackTitle() (string, error)
- func GetDefaultBranch(remote string) (string, error)
- func GetRemoteURL(remoteAlias string) (string, error)
- func GitUserName() ([]byte, error)
- func InitGitRepo(t *testing.T) string
- func InitGitRepoWithCommit(t *testing.T) string
- func IsValidURL(u string) bool
- func ListTags() ([]string, error)
- func ParseDefaultBranch(output []byte) (string, error)
- func ParseURL(rawURL string) (*url.URL, error)
- func Push(remote string, ref string, cmdOut, cmdErr io.Writer) error
- func RemoteBranchExists(branch string, gr GitRunner) bool
- func RunClone(cloneURL string, target string, args []string) (string, error)
- func RunCmd(args []string) error
- func SetConfig(key, value string) error
- func SetLocalConfig(key, value string) error
- func SetRemoteConfig(remote, key, value string) error
- func SetUpstream(remote string, branch string, cmdOut, cmdErr io.Writer) error
- func StackRootDir(title string) (string, error)
- func UncommittedChangeCount() (int, error)
- func UpdateStackRefFile(title string, s StackRef) error
- type BranchConfig
- type Commit
- type GitRunner
- type Ref
- type Remote
- type RemoteSet
- type SSHAliasMap
- type Stack
- func (s *Stack) BaseBranch(gr GitRunner) (string, error)
- func (s *Stack) Branches() []string
- func (s Stack) Empty() bool
- func (s *Stack) First() StackRef
- func (s *Stack) IndexAt(ref StackRef) int
- func (s *Stack) Iter() iter.Seq[StackRef]
- func (s *Stack) Iter2() iter.Seq2[int, StackRef]
- func (s *Stack) Last() StackRef
- func (s Stack) RefFromBranch(branch string) (StackRef, error)
- func (s *Stack) RemoveBranch(ref StackRef, gr GitRunner) error
- func (s *Stack) RemoveRef(ref StackRef, gr GitRunner) error
- type StackRef
- type StandardGitCommand
Constants ¶
const BaseBranchFile = "BASE_BRANCH"
const DefaultRemote = "origin"
Variables ¶
var ErrNotOnAnyBranch = errors.New("you're not on any Git branch (a 'detached HEAD' state).")
ErrNotOnAnyBranch indicates that the user is in detached HEAD state
var SetRemoteResolution = func(name, resolution string) error { return SetRemoteConfig(name, "glab-resolved", resolution) }
var StackLocation = filepath.Join(".git", "stacked")
var ToplevelDir = func() (string, error) { showCmd := exec.Command("git", "rev-parse", "--show-toplevel") output, err := run.PrepareCmd(showCmd).Output() return firstLine(output), err }
ToplevelDir returns the top-level directory path of the current repository
Functions ¶
func AddStackBaseBranch ¶
func AddStackRefDir ¶
func AddStackRefFile ¶
func AddUpstreamRemote ¶
func CheckoutBranch ¶
func CheckoutNewBranch ¶
func CommitBody ¶
func CreateBranches ¶
func CurrentBranch ¶
CurrentBranch reads the checked-out branch for the git repository
func DeleteLocalBranch ¶
func DeleteStackRefFile ¶
func DescribeByTags ¶
DescribeByTags gives a description of the current object. Non-annotated tags are considered. Reference: https://git-scm.com/docs/git-describe
func GetAllConfig ¶
GetConfig returns the local config value associated with the provided key. If there are multiple values associated with the key, they are all returned.
func GetCurrentStackTitle ¶
func GetDefaultBranch ¶
GetDefaultBranch finds and returns the remote's default branch
func GetRemoteURL ¶
func GitUserName ¶
func InitGitRepo ¶
func InitGitRepoWithCommit ¶
func IsValidURL ¶
IsValidUrl tests a string to determine if it is a valid Git url or not.
func ParseDefaultBranch ¶
func RemoteBranchExists ¶
func SetLocalConfig ¶
func SetRemoteConfig ¶
func SetUpstream ¶
SetUpstream sets the upstream (tracking) of a branch
func StackRootDir ¶
func UncommittedChangeCount ¶
func UpdateStackRefFile ¶
Types ¶
type BranchConfig ¶
func ReadBranchConfig ¶
func ReadBranchConfig(branch string) BranchConfig
ReadBranchConfig parses the `branch.BRANCH.(remote|merge)` part of git config
type Remote ¶
Remote is a parsed git remote
type SSHAliasMap ¶
SSHAliasMap encapsulates the translation of SSH hostname aliases
func ParseSSHConfig ¶
func ParseSSHConfig() SSHAliasMap
ParseSSHConfig constructs a map of SSH hostname aliases based on user and system configuration files
func (SSHAliasMap) Translator ¶
func (m SSHAliasMap) Translator() func(*url.URL) *url.URL
Translator returns a function that applies hostname aliases to URLs
type Stack ¶
Stack represents a stacked diff data structure. Refs are structured as a doubly linked list where the links are identified with the StackRef.Prev and StackRef.Next fields. The StackRef.SHA is the id that the former two fields can point to. All stacks must be created with GatherStackRefs which validates the stack for consistency.
func GatherStackRefs ¶
type StackRef ¶
type StackRef struct { Prev string `json:"prev"` Branch string `json:"branch"` SHA string `json:"sha"` Next string `json:"next"` MR string `json:"mr"` Description string `json:"description"` }
func (StackRef) Empty ¶
Empty returns true if the stack ref does not have an associated SHA (commit). This indicates that the StackRef is invalid.
func (StackRef) IsFirst ¶
IsFirst returns true if the stack ref is the first of the stack. A stack ref is considered the first if it does not reference any previous ref.
type StandardGitCommand ¶
type StandardGitCommand struct{}