Documentation
¶
Index ¶
- Variables
- func CurrentBackendName() string
- func ParseURL(rawURL string) (u *url.URL, err error)
- func RegisterBackend(backend Backend) error
- func RegisteredBackends() []string
- func UseBackend(name string) error
- type AuthMethod
- type Backend
- type Branch
- type CloneOptions
- type Config
- type Hash
- type Reference
- type ReferenceName
- type Remote
- type RemoteConfig
- type RepositoryBackend
- type TeaRepo
- func (r TeaRepo) AddRemote(name, remoteURL string) error
- func (r TeaRepo) Config() (*Config, error)
- func (r TeaRepo) Fetch(remoteName string, refspecs []string, auth *AuthMethod) error
- func (r TeaRepo) GetOrCreateRemote(remoteURL, newRemoteName string) (*Remote, error)
- func (r TeaRepo) GetRemote(remoteURL string) (*Remote, error)
- func (r TeaRepo) Head() (*Reference, error)
- func (r TeaRepo) PushToCreatAgitFlowPR(remoteName, head, base, topic, title, description string, auth *AuthMethod) error
- func (r TeaRepo) Remote(remoteName string) (*Remote, error)
- func (r TeaRepo) RemoteURL(remoteName string) (*url.URL, error)
- func (r TeaRepo) Remotes() ([]*Remote, error)
- func (r TeaRepo) SetBranchUpstream(branchName, remoteName, remoteBranch string) error
- func (r TeaRepo) TeaCheckout(ref ReferenceName) error
- func (r TeaRepo) TeaCreateBranch(localBranchName, remoteBranchName, remoteName string) error
- func (r TeaRepo) TeaDeleteLocalBranch(branch *Branch) error
- func (r TeaRepo) TeaDeleteRemoteBranch(remoteName, remoteBranch string, auth *AuthMethod) error
- func (r TeaRepo) TeaFindBranchByName(branchName, repoURL string) (b *Branch, err error)
- func (r TeaRepo) TeaFindBranchBySha(sha, repoURL string) (b *Branch, err error)
- func (r TeaRepo) TeaFindBranchRemote(branchName, hash string) (*Remote, error)
- func (r TeaRepo) TeaGetCurrentBranchNameAndSHA() (string, string, error)
- func (r TeaRepo) TeaRemoteURL(name string) (auth *url.URL, err error)
- func (r TeaRepo) WorkTree() string
- type URLParser
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRepositoryNotExists indicates the requested path is not inside a git repository. ErrRepositoryNotExists = errors.New("repository does not exist") // ErrBranchExists indicates the requested branch already exists locally. ErrBranchExists = errors.New("branch already exists") )
Functions ¶
func CurrentBackendName ¶
func CurrentBackendName() string
CurrentBackendName returns the active backend name.
func RegisterBackend ¶
RegisterBackend makes a git backend available for later switching.
func RegisteredBackends ¶
func RegisteredBackends() []string
RegisteredBackends returns all registered backend names.
func UseBackend ¶
UseBackend switches the active git backend implementation.
Types ¶
type AuthMethod ¶
type AuthMethod struct {
Scheme string
Username string
Password string
KeyFile string
KeyPassphrase string
}
AuthMethod carries backend-agnostic authentication information for git operations.
func GetAuthForURL ¶
func GetAuthForURL(remoteURL *url.URL, authToken, keyFile string, passwordCallback pwCallback) (*AuthMethod, error)
GetAuthForURL returns backend-agnostic auth settings for git network operations.
type Backend ¶
type Backend interface {
Name() string
Open(path string) (RepositoryBackend, error)
Clone(path, remoteURL string, auth *AuthMethod, opts CloneOptions) (RepositoryBackend, error)
}
Backend opens and clones repositories using a concrete git implementation.
type Branch ¶
type Branch struct {
Name string
Remote string
Merge ReferenceName
}
Branch stores branch configuration.
type CloneOptions ¶
CloneOptions describes repository clone behavior.
type Config ¶
type Config struct {
Remotes map[string]*RemoteConfig
Branches map[string]*Branch
}
Config mirrors the repository config fields tea needs.
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
Reference stores a resolved git ref and its hash.
type ReferenceName ¶
type ReferenceName string
ReferenceName identifies a git reference.
func NewBranchReferenceName ¶
func NewBranchReferenceName(name string) ReferenceName
NewBranchReferenceName constructs a local branch ref name.
func NewRemoteReferenceName ¶
func NewRemoteReferenceName(remote, name string) ReferenceName
NewRemoteReferenceName constructs a remote-tracking ref name.
func (ReferenceName) IsBranch ¶
func (r ReferenceName) IsBranch() bool
IsBranch reports whether the reference points to a local branch.
func (ReferenceName) IsRemote ¶
func (r ReferenceName) IsRemote() bool
IsRemote reports whether the reference points to a remote-tracking branch.
func (ReferenceName) IsTag ¶
func (r ReferenceName) IsTag() bool
IsTag reports whether the reference points to a tag.
func (ReferenceName) Short ¶
func (r ReferenceName) Short() string
Short returns the short display name for the reference.
func (ReferenceName) String ¶
func (r ReferenceName) String() string
type Remote ¶
type Remote struct {
// contains filtered or unexported fields
}
Remote wraps a configured git remote.
func (*Remote) Config ¶
func (r *Remote) Config() *RemoteConfig
Config returns the remote configuration.
type RemoteConfig ¶
RemoteConfig stores remote configuration.
type RepositoryBackend ¶
type RepositoryBackend interface {
WorkTree() string
Config() (*Config, error)
Head() (*Reference, error)
AddRemote(name, remoteURL string) error
SetBranchUpstream(branchName, remoteName, remoteBranch string) error
Fetch(remoteName string, refspecs []string, auth *AuthMethod) error
CreateTrackingBranch(localBranchName, remoteBranchName, remoteName string) error
Checkout(ref ReferenceName) error
DeleteLocalBranch(branchName string) error
DeleteRemoteBranch(remoteName, remoteBranch string, auth *AuthMethod) error
ListReferences(prefixes ...string) ([]*Reference, error)
PushToAgitFlowPR(remoteName, head, base, topic string, pushOptions map[string]string, auth *AuthMethod) error
}
RepositoryBackend is the backend abstraction used by TeaRepo.
type TeaRepo ¶
type TeaRepo struct {
// contains filtered or unexported fields
}
TeaRepo wraps a local git repository behind a swappable backend.
func RepoForWorkdir ¶
RepoForWorkdir tries to open the git repository in the local directory for reading or modification.
func RepoFromPath ¶
RepoFromPath tries to open the git repository by path.
func (TeaRepo) Fetch ¶
func (r TeaRepo) Fetch(remoteName string, refspecs []string, auth *AuthMethod) error
Fetch fetches updates from the named remote.
func (TeaRepo) GetOrCreateRemote ¶
GetOrCreateRemote tries to match a Remote of the repo via the given URL. If no match is found, a new Remote with `newRemoteName` is created. Matching is based on the normalized URL, accepting different protocols.
func (TeaRepo) GetRemote ¶
GetRemote tries to match a Remote of the repo via the given URL. Matching is based on the normalized URL, accepting different protocols.
func (TeaRepo) PushToCreatAgitFlowPR ¶
func (r TeaRepo) PushToCreatAgitFlowPR(remoteName, head, base, topic, title, description string, auth *AuthMethod) error
PushToCreatAgitFlowPR pushes the given head to the refs/for/<base>/<topic> ref on the remote to create an agit flow PR.
func (TeaRepo) SetBranchUpstream ¶
SetBranchUpstream configures the branch's upstream remote.
func (TeaRepo) TeaCheckout ¶
func (r TeaRepo) TeaCheckout(ref ReferenceName) error
TeaCheckout checks out the given branch in the worktree.
func (TeaRepo) TeaCreateBranch ¶
TeaCreateBranch creates a new branch in the repo, tracking from another branch.
func (TeaRepo) TeaDeleteLocalBranch ¶
TeaDeleteLocalBranch removes the given branch locally.
func (TeaRepo) TeaDeleteRemoteBranch ¶
func (r TeaRepo) TeaDeleteRemoteBranch(remoteName, remoteBranch string, auth *AuthMethod) error
TeaDeleteRemoteBranch removes the given branch on the given remote via git protocol.
func (TeaRepo) TeaFindBranchByName ¶
TeaFindBranchByName returns a branch that is at the the given local and remote names and syncs to the given remote repo. This method is less precise than TeaFindBranchBySha(), but may be desirable if local and remote branch have diverged.
func (TeaRepo) TeaFindBranchBySha ¶
TeaFindBranchBySha returns a branch that is at the the given SHA and syncs to the given remote repo.
func (TeaRepo) TeaFindBranchRemote ¶
TeaFindBranchRemote gives the first remote that has a branch with the same name or sha, depending on what is passed in. This function is needed, as git does not always define branches in .git/config with remote entries. Priority order is: first match of sha and branch -> first match of branch -> first match of sha.
func (TeaRepo) TeaGetCurrentBranchNameAndSHA ¶
TeaGetCurrentBranchNameAndSHA return the name and sha of the branch witch is currently active.
func (TeaRepo) TeaRemoteURL ¶
TeaRemoteURL returns the first url entry for the given remote name.