Documentation ¶
Index ¶
- Constants
- func GetAuth(repo *config.Repo) (transport.AuthMethod, error)
- func LocalBranches(s storer.ReferenceStorer) (storer.ReferenceIter, error)
- func StringInSlice(a string, list []string) bool
- func WorkDir(r Repo) string
- type Repo
- type Repository
- func (r *Repository) Branch() plumbing.ReferenceName
- func (r *Repository) CheckRef(ref string) error
- func (r *Repository) CheckoutBranch(branch plumbing.ReferenceName) error
- func (r *Repository) Clone(path string) error
- func (r *Repository) DiffStatus(ref string) (object.Changes, error)
- func (r *Repository) GetConfig() *config.Repo
- func (r *Repository) GetStorer() storage.Storer
- func (r *Repository) Name() string
- func (r *Repository) Pull(branchName string) error
Constants ¶
const ( RepositoryError = iota // Unused, it will always get returned with an err RepositoryCloned RepositoryOpened )
Status codes for Repository object creation
Variables ¶
This section is empty.
Functions ¶
func GetAuth ¶
func GetAuth(repo *config.Repo) (transport.AuthMethod, error)
GetAuth returns AuthMethod based on the passed flags
func LocalBranches ¶
func LocalBranches(s storer.ReferenceStorer) (storer.ReferenceIter, error)
LocalBranches returns an iterator to iterate only over local branches.
func StringInSlice ¶
StringInSlice checks if value exists within slice.
Types ¶
type Repo ¶
type Repo interface { Name() string Pull(string) error CheckoutBranch(plumbing.ReferenceName) error CheckRef(string) error Head() (*plumbing.Reference, error) Lock() Unlock() DiffStatus(string) (object.Changes, error) Worktree() (*git.Worktree, error) Branch() plumbing.ReferenceName GetConfig() *config.Repo GetStorer() storage.Storer ResolveRevision(plumbing.Revision) (*plumbing.Hash, error) }
Repo interface represents Repository
type Repository ¶
type Repository struct { sync.Mutex *git.Repository Config *config.Repo Authentication transport.AuthMethod }
Repository is used to hold the git repository object and it's configuration
func LoadRepos ¶
func LoadRepos(cfg *config.Config) ([]*Repository, error)
LoadRepos populates Repository slice from configuration. It also handles cloning of the repository if not present
func New ¶
func New(repoBasePath string, repoConfig *config.Repo, auth transport.AuthMethod) (*Repository, int, error)
New is used to construct a new repository object from the configuration
func (*Repository) Branch ¶
func (r *Repository) Branch() plumbing.ReferenceName
Branch returns the branch name
func (*Repository) CheckRef ¶
func (r *Repository) CheckRef(ref string) error
CheckRef checks whether a particular ref is part of the repository
func (*Repository) CheckoutBranch ¶
func (r *Repository) CheckoutBranch(branch plumbing.ReferenceName) error
CheckoutBranch performs a checkout on the specific branch
func (*Repository) Clone ¶
func (r *Repository) Clone(path string) error
Clone the repository. Cloning will only checkout tracked branches. A destination path to clone to needs to be provided
func (*Repository) DiffStatus ¶
func (r *Repository) DiffStatus(ref string) (object.Changes, error)
DiffStatus compares the current workdir with a target ref and return the modified files
func (*Repository) GetConfig ¶
func (r *Repository) GetConfig() *config.Repo
GetConfig returns config *Repo
func (*Repository) GetStorer ¶
func (r *Repository) GetStorer() storage.Storer
GetStorer returns Storer
func (*Repository) Pull ¶
func (r *Repository) Pull(branchName string) error
Pull a repository branch, which is equivalent to a fetch and merge