plain

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRepositoriesNotFound is returned when there's no any repository in
	// a certain directory.
	ErrRepositoriesNotFound = errors.NewKind("couldn't find any repository")
)

Functions

func IsFirstRepositoryBare

func IsFirstRepositoryBare(fs billy.Filesystem, path string) (bool, error)

IsFirstRepositoryBare walks the given path containing repositories, checking if the first found repository is bare. If it can't find repositories an ErrRepositoriesNotFound will be returned.

func IsRepository

func IsRepository(fs billy.Filesystem, path string, isBare bool) (bool, error)

IsRepository return true if the given path in the given filesystem contains a valid repository.

The identifciation method is based on the stat of 3 different files/folder, cgit, makes a extra validation in the content on the HEAD file.

Types

type Library

type Library struct {
	// contains filtered or unexported fields
}

Library represents a borges.Library implementation based on billy.Filesystems.

func NewLibrary

func NewLibrary(id borges.LibraryID, options *LibraryOptions) *Library

NewLibrary returns a new empty Library instance.

func (*Library) AddLibrary

func (l *Library) AddLibrary(lib *Library)

AddLibrary adds a Library to this Library.

func (*Library) AddLocation

func (l *Library) AddLocation(loc *Location)

AddLocation adds a Location to this Library.

func (*Library) Get

func (l *Library) Get(id borges.RepositoryID, m borges.Mode) (borges.Repository, error)

Get open a repository with the given RepositoryID, it itereates all the library locations until this repository is found. If a repository with the given RepositoryID can't be found the ErrRepositoryNotExists is returned.

func (*Library) GetOrInit

func (l *Library) GetOrInit(borges.RepositoryID) (borges.Repository, error)

GetOrInit is not implemented. It honors the borges.Library interface.

func (*Library) Has

func (l *Library) Has(id borges.RepositoryID) (bool, borges.LibraryID, borges.LocationID, error)

Has returns true, the LibraryID and the LocationID if the given RepositoryID matches any repository at any location belonging to this Library.

func (*Library) ID

func (l *Library) ID() borges.LibraryID

ID returns the borges.LibraryID for this Library.

func (*Library) Init

func (l *Library) Init(borges.RepositoryID) (borges.Repository, error)

Init is not implemented. It honors the borges.Library interface.

func (*Library) Libraries

func (l *Library) Libraries() (borges.LibraryIterator, error)

Libraries returns a LibraryIterator that iterates through all libraries contained in this Library.

func (*Library) Library

func (l *Library) Library(id borges.LibraryID) (borges.Library, error)

Library returns the Library with the given LibraryID, if a library can't be found ErrLibraryNotExists is returned.

func (*Library) Location

func (l *Library) Location(id borges.LocationID) (borges.Location, error)

Location returns the a Location with the given ID, if exists, otherwise ErrLocationNotExists is returned.

func (*Library) Locations

func (l *Library) Locations() (borges.LocationIterator, error)

Locations returns a LocationIterator that iterates through all locations contained in this Library.

func (*Library) Repositories

func (l *Library) Repositories(
	mode borges.Mode,
) (borges.RepositoryIterator, error)

Repositories returns a RepositoryIterator that iterates through all the repositories contained in all Location contained in this Library.

type LibraryOptions

type LibraryOptions struct {
	// Timeout set a timeout for library operations. Some operations could
	// potentially take long so timing out them will make an error be
	// returned. A 0 value sets a default value of 20 seconds.
	Timeout time.Duration
}

LibraryOptions hold configuration options for the library.

type Location

type Location struct {
	// contains filtered or unexported fields
}

Location implements borges.Location for plain repositories stored in a billy.Filesystem.

func NewLocation

func NewLocation(id borges.LocationID, fs billy.Filesystem, options *LocationOptions) (*Location, error)

NewLocation returns a new Location based on the given ID and Filesystem with the given LocationOptions.

func (*Location) Get

func (l *Location) Get(id borges.RepositoryID, mode borges.Mode) (borges.Repository, error)

Get open a repository with the given RepositoryID, this operation doesn't perform any read operation. If a repository with the given RepositoryID already exists ErrRepositoryExists is returned.

func (*Location) GetOrInit

func (l *Location) GetOrInit(id borges.RepositoryID) (borges.Repository, error)

GetOrInit get the requested repository based on the given id, or inits a new repository. If the repository is opened this will be done in RWMode.

func (*Location) Has

func (l *Location) Has(id borges.RepositoryID) (bool, error)

Has returns true if the given RepositoryID matches any repository at this location.

func (*Location) ID

func (l *Location) ID() borges.LocationID

ID returns the ID for this Location.

func (*Location) Init

func (l *Location) Init(id borges.RepositoryID) (borges.Repository, error)

Init initializes a new Repository at this Location.

func (*Location) Library

func (l *Location) Library() borges.Library

Library implements the borges.Location interface.

func (*Location) Repositories

func (l *Location) Repositories(m borges.Mode) (borges.RepositoryIterator, error)

Repositories returns a RepositoryIterator that iterates through all the repositories contained in this Location.

func (*Location) RepositoryPath

func (l *Location) RepositoryPath(id borges.RepositoryID) string

RepositoryPath returns the location in the filesystem for a given RepositoryID.

type LocationIterator

type LocationIterator struct {
	// contains filtered or unexported fields
}

LocationIterator iterates all the repositories contained in a Location.

func NewLocationIterator

func NewLocationIterator(l *Location, m borges.Mode) (*LocationIterator, error)

NewLocationIterator returns a new LocationIterator for a given Location.

func (*LocationIterator) Close

func (iter *LocationIterator) Close()

Close releases any resources used by the iterator.

func (*LocationIterator) ForEach

func (iter *LocationIterator) ForEach(cb func(borges.Repository) error) error

ForEach call the function for each object contained on this iter until an error happens or the end of the iter is reached. If ErrStop is sent the iteration is stop but no error is returned. The iterator is closed.

func (*LocationIterator) Next

func (iter *LocationIterator) Next() (borges.Repository, error)

Next returns the next repository from the iterator. If the iterator has reached the end it will return io.EOF as an error.

type LocationOptions

type LocationOptions struct {
	// Base defines if the location handle Bare git repositories or not.
	Bare bool
	// Transactional defines if the write operations are done in a transactional
	// mode or not.
	Transactional bool
	// TemporalFilesystem defines the filesystem used for any temporal file
	// like transactional operation files. If empty and Transactional is true
	// a new memfs filesystem will be used.
	TemporalFilesystem billy.Filesystem
	// Cache specifies the shared cache used in repositories. If not defined
	// a new default cache will be created for each repository.
	Cache cache.Object
	// Performance enables performance options in read only git repositories
	// (ExclusiveAccess and KeepDescriptors).
	Performance bool
}

LocationOptions contains configuration options for a plain.Location.

func (*LocationOptions) Validate

func (o *LocationOptions) Validate() error

Validate validates the fields and sets the default values.

type Repository

type Repository struct {
	*git.Repository
	// contains filtered or unexported fields
}

Repository represents a git plain repository.

func (*Repository) Close

func (r *Repository) Close() error

Close closes the repository, if the repository was opened in transactional Mode, will delete any write operation pending to be written.

func (*Repository) Commit

func (r *Repository) Commit() (err error)

Commit persists all the write operations done since was open, if the repository wasn't opened in a Location with Transactions enable returns ErrNonTransactional.

func (*Repository) FS

func (r *Repository) FS() billy.Filesystem

FS returns the filesystem to read or write directly to the repository or nil if not available.

func (*Repository) ID

func (r *Repository) ID() borges.RepositoryID

ID returns the RepositoryID.

func (*Repository) Location

func (r *Repository) Location() borges.Location

Location implements the borges.Repository interface.

func (*Repository) Mode

func (r *Repository) Mode() borges.Mode

Mode returns the Mode how it was opened.

func (*Repository) R

func (r *Repository) R() *git.Repository

R returns the git.Repository.

Jump to

Keyboard shortcuts

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