Documentation ¶
Index ¶
- Variables
- type Branch
- type CloneOptions
- type Commit
- type CredType
- type Credential
- type CredentialsAsPlainText
- type CredentialsAsSSHAgent
- type CredentialsAsSSHKey
- type DeltaStatus
- type Diff
- type DiffDelta
- type DiffFile
- type FetchOptions
- type IndexType
- type MergeOptions
- type OptionsWithCreds
- type Ref
- type RefType
- type Repository
- func (r *Repository) AddToIndex(e *StatusEntry) error
- func (r *Repository) AddToStash(s *Signature, message string, flags StashFlag) (*StashedItem, error)
- func (r *Repository) Branches() ([]*Branch, error)
- func (r *Repository) Commit(message string, author ...*Signature) (*Commit, error)
- func (r *Repository) Commits() ([]*Commit, error)
- func (r *Repository) Fetch(opts *FetchOptions) error
- func (r *Repository) LoadHead() error
- func (r *Repository) LoadStatus() (*Status, error)
- func (r *Repository) Merge(ref string, opts *MergeOptions) error
- func (r *Repository) Path() string
- func (r *Repository) RemoveFromIndex(e *StatusEntry) error
- func (r *Repository) Stashes() ([]*StashedItem, error)
- func (r *Repository) Tags() ([]*Tag, error)
- type Signature
- type StashFlag
- type StashedItem
- type State
- type Status
- type StatusEntry
- type StatusEntryType
- type Tag
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAuthenticationRequired as the name implies ErrAuthenticationRequired = errors.New("authentication required") // ErrAuthenticationType means that given credentials cannot be used for given repository url ErrAuthenticationType = errors.New("authentication method is not valid") // ErrClone is a generic clone error ErrClone = errors.New("cannot clone repo") // ErrCannotOpenRepo is returned when the repo couldn't be loaded from filesystem ErrCannotOpenRepo = errors.New("cannot load repository") // ErrCreateCallbackFail is reuterned when an error occurred while creating callbacks ErrCreateCallbackFail = errors.New("cannot create default callbacks") // ErrNoRemoteName if the remote name is empty while fetching ErrNoRemoteName = errors.New("remote name not specified") // ErrNotValidRemoteName is returned if the given remote name is not found ErrNotValidRemoteName = errors.New("not a valid remote name") // ErrAlreadyUpToDate if the repo is up-to-date ErrAlreadyUpToDate = errors.New("already up-to-date") // ErrFastForwardOnly if the merge can be made by fast-forward ErrFastForwardOnly = errors.New("fast-forward only") // ErrBranchNotFound is returned when the given ref can't found ErrBranchNotFound = errors.New("cannot locate remote-tracking branch") // ErrEntryNotIndexed is returned when the entry is not indexed ErrEntryNotIndexed = errors.New("entry is not indexed") )
Functions ¶
This section is empty.
Types ¶
type Branch ¶
type Branch struct { Name string FullName string Hash string Head bool Ahead int Behind int Upstream *Branch // contains filtered or unexported fields }
Branch is a wrapper of lib.Branch object
type CloneOptions ¶
type CloneOptions struct { Bare bool Recursive bool Depth int Credentials Credential }
CloneOptions are mostly used git clone options from a remote
type Commit ¶
type Commit struct { Author *Signature Message string Summary string Hash string // contains filtered or unexported fields }
Commit is the wrapper of actual lib.Commit object
type CredType ¶
type CredType uint8
CredType defines the credentials type for authentication with remote
type Credential ¶
type Credential interface { // Type returns the type of credential Type() CredType }
Credential is an interface for specfying its type
type CredentialsAsPlainText ¶
CredentialsAsPlainText contains basic username and password information
func (*CredentialsAsPlainText) Type ¶
func (c *CredentialsAsPlainText) Type() CredType
Type returns the type of credential
type CredentialsAsSSHAgent ¶
type CredentialsAsSSHAgent struct {
UserName string
}
CredentialsAsSSHAgent holds only usernmae if ssh daemon working
func (*CredentialsAsSSHAgent) Type ¶
func (c *CredentialsAsSSHAgent) Type() CredType
Type returns the type of credential
type CredentialsAsSSHKey ¶
type CredentialsAsSSHKey struct { UserName string PublicKeyPath string PrivateKeyPath string Passphrase string }
CredentialsAsSSHKey contains ssh file paths and related information
func (*CredentialsAsSSHKey) Type ¶
func (c *CredentialsAsSSHKey) Type() CredType
Type returns the type of credential
type DeltaStatus ¶
type DeltaStatus int
DeltaStatus ondicates a files status in a diff
const ( DeltaUnmodified DeltaStatus = iota DeltaAdded DeltaDeleted DeltaModified DeltaRenamed DeltaCopied DeltaIgnored DeltaUntracked DeltaTypeChange DeltaUnreadable DeltaConflicted )
Delta status of a file e.g. on a commit
type Diff ¶
type Diff struct {
// contains filtered or unexported fields
}
Diff is the wrapper for a diff content acquired from repo
type DiffDelta ¶
type DiffDelta struct { Status DeltaStatus OldFile *DiffFile NewFile *DiffFile Patch string Commit *Commit }
DiffDelta holds delta status, file changes and the actual patchs
func (*DiffDelta) DeltaStatusString ¶
DeltaStatusString retruns delta status as string
type FetchOptions ¶
type FetchOptions struct { Remote string Credentials Credential Prune bool All bool Tags bool }
FetchOptions provides common options for fetch command
type IndexType ¶
type IndexType int
IndexType describes the different stages a status entry can be in
type MergeOptions ¶
type MergeOptions struct { Message string NoFF bool FailOnConflict bool IgnoreAlreadyUpToDate bool }
MergeOptions defines common options for merge operation
type OptionsWithCreds ¶
type OptionsWithCreds interface {
// contains filtered or unexported methods
}
OptionsWithCreds provides an interface to get fetch callbacks
type Repository ¶
type Repository struct { RefMap map[string][]Ref Head *Branch // contains filtered or unexported fields }
Repository is the wrapper and main interface to git repository
func Clone ¶
func Clone(path string, url string, opts *CloneOptions) (*Repository, error)
Clone fetches a git repository from a given url
func Open ¶
func Open(path string) (*Repository, error)
Open load the repository from the filesystem
func (*Repository) AddToIndex ¶
func (r *Repository) AddToIndex(e *StatusEntry) error
AddToIndex is the wrapper of "git add /path/to/file" command
func (*Repository) AddToStash ¶ added in v0.1.5
func (r *Repository) AddToStash(s *Signature, message string, flags StashFlag) (*StashedItem, error)
AddToStash saves the modifications to stash
func (*Repository) Branches ¶
func (r *Repository) Branches() ([]*Branch, error)
Branches loads branches with the lib's branch iterator loads both remote and local branches
func (*Repository) Commit ¶
func (r *Repository) Commit(message string, author ...*Signature) (*Commit, error)
Commit adds a new commit onject to repository warning: this function does not check if the changes are indexed
func (*Repository) Commits ¶
func (r *Repository) Commits() ([]*Commit, error)
Commits returns all of the commits of the repository
func (*Repository) Fetch ¶
func (r *Repository) Fetch(opts *FetchOptions) error
Fetch downloads refs from given remote
func (*Repository) LoadHead ¶ added in v0.1.5
func (r *Repository) LoadHead() error
LoadHead can be used to refresh HEAD ref
func (*Repository) LoadStatus ¶
func (r *Repository) LoadStatus() (*Status, error)
LoadStatus simply emulates a "git status" and returns the result
func (*Repository) Merge ¶
func (r *Repository) Merge(ref string, opts *MergeOptions) error
Merge incorporates changes from the given branch into the current branch
func (*Repository) Path ¶
func (r *Repository) Path() string
Path returns the filesystem location of the repository
func (*Repository) RemoveFromIndex ¶
func (r *Repository) RemoveFromIndex(e *StatusEntry) error
RemoveFromIndex is the wrapper of "git reset path/to/file" command
func (*Repository) Stashes ¶ added in v0.1.5
func (r *Repository) Stashes() ([]*StashedItem, error)
Stashes returns the stashed items of the repository
type StashFlag ¶ added in v0.1.5
type StashFlag int
StashFlag is the flag that affect the stash save operation.
type StashedItem ¶ added in v0.1.5
type StashedItem struct { Index int Hash string Message string // contains filtered or unexported fields }
StashedItem is a change that stashed into the repository
type Status ¶
type Status struct { State State Entities []*StatusEntry }
Status contains all git status data
type StatusEntry ¶
type StatusEntry struct { EntryType StatusEntryType // contains filtered or unexported fields }
StatusEntry contains data for a single status entry
func (*StatusEntry) Indexed ¶
func (e *StatusEntry) Indexed() bool
Indexed true if entry added to index
func (*StatusEntry) StatusEntryString ¶
func (e *StatusEntry) StatusEntryString() string
StatusEntryString returns entry status in pretty format
func (*StatusEntry) String ¶
func (e *StatusEntry) String() string
Indexed true if entry added to index
type StatusEntryType ¶
type StatusEntryType int
StatusEntryType describes the type of change a status entry has undergone
const ( StatusEntryTypeNew StatusEntryType = iota StatusEntryTypeModified StatusEntryTypeDeleted StatusEntryTypeRenamed StatusEntryTypeUntracked StatusEntryTypeTypeChange StatusEntryTypeConflicted )
The set of supported StatusEntryTypes