repo

package
v0.0.0-...-b8e83fa Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Open() error
	Clone(co *git.CloneOptions) error
	Fetch(fo *git.FetchOptions) error
	Worktree() (*git.Worktree, error)
	Head() (*plumbing.Reference, error)
	ResolveRevision(plumbing.Revision) (*plumbing.Hash, error)
	IsOpen() bool
	SetFilesystem(billy.Filesystem)
	SetStorer(s storage.Storer)
	Close()
}

Adapter is abstraction to SVC

func NewGitDriver

func NewGitDriver(fs billy.Filesystem, s storage.Storer) Adapter

NewGitDriver returns GitDriver with given storer and Filesystem

type ErrNoOpenRepo

type ErrNoOpenRepo struct {
}

ErrNoOpenRepo returned if repository is not opened by git driver

func (ErrNoOpenRepo) Error

func (e ErrNoOpenRepo) Error() string

type ErrParseURL

type ErrParseURL struct {
	URL string
}

ErrParseURL returned if there is error when parsing URL

func (ErrParseURL) Error

func (e ErrParseURL) Error() string

type GitDriver

type GitDriver struct {
	*git.Repository
	Filesystem billy.Filesystem
	Storer     storage.Storer
}

GitDriver implements repository interface

func (*GitDriver) Clone

func (g *GitDriver) Clone(co *git.CloneOptions) error

Clone implements repository interface

func (*GitDriver) Close

func (g *GitDriver) Close()

Close sets repository to nil, IsOpen() function will return false now

func (*GitDriver) IsOpen

func (g *GitDriver) IsOpen() bool

IsOpen returns true if repository is already cloned

func (*GitDriver) Open

func (g *GitDriver) Open() error

Open implements repository interface

func (*GitDriver) SetFilesystem

func (g *GitDriver) SetFilesystem(fs billy.Filesystem)

SetFilesystem updates given Filesystem in GitDriver.Filesystem

func (*GitDriver) SetStorer

func (g *GitDriver) SetStorer(s storage.Storer)

SetStorer updates given Storer in GitDriver.Filesystem

type OptionsBuilder

type OptionsBuilder interface {
	ToAuth() (transport.AuthMethod, error)
	ToCloneOptions(auth transport.AuthMethod) *git.CloneOptions
	ToCheckoutOptions() *git.CheckoutOptions
	ToFetchOptions(auth transport.AuthMethod) *git.FetchOptions
	URL() string
}

OptionsBuilder interface provides specification for a repository implementation

type Repository

type Repository struct {
	Driver Adapter
	OptionsBuilder
	Name string
}

Repository container holds Filesystem, spec and open repository object Abstracts git repository and allows for easy cloning, checkout and update of git repos

func NewRepository

func NewRepository(basePath string, builder OptionsBuilder) (*Repository, error)

NewRepository create repository object, with real filesystem on disk basePath is used to calculate final path where to clone/open the repository

func (*Repository) Checkout

func (repo *Repository) Checkout() error

Checkout git repository, ToCheckoutOptions method will be used go get CheckoutOptions

func (*Repository) Clone

func (repo *Repository) Clone() error

Clone given repository

func (*Repository) Download

func (repo *Repository) Download(noCheckout bool) error

Download will clone and checkout repository based on auth and checkout fields of the Repository object If repository is already cloned, it will be opened and checked out to configured hash,branch,tag etc... no remotes will be modified in this case, also no refs will be updated. enforce parameter is used to simulate git reset --hard option. If you want to enforce state of the repository, please delete current git repository before downloading.

func (*Repository) Fetch

func (repo *Repository) Fetch() error

Fetch fetches remote refs

func (*Repository) Open

func (repo *Repository) Open() error

Open the repository

func (*Repository) Update

func (repo *Repository) Update() error

Update fetches new refs, and checkout according to checkout options

Jump to

Keyboard shortcuts

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