repository

package
v0.0.0-...-02502d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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

func StringInSlice(a string, list []string) bool

StringInSlice checks if value exists within slice.

func WorkDir

func WorkDir(r Repo) string

WorkDir returns working directory for a local copy of the repository.

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) Name

func (r *Repository) Name() string

Name returns the repository name

func (*Repository) Pull

func (r *Repository) Pull(branchName string) error

Pull a repository branch, which is equivalent to a fetch and merge

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL