Documentation
¶
Index ¶
- Variables
- func IsFirstRepositoryBare(fs billy.Filesystem, path string) (bool, error)
- func IsRepository(fs billy.Filesystem, path string, isBare bool) (bool, error)
- type Library
- func (l *Library) AddLibrary(lib *Library)
- func (l *Library) AddLocation(loc *Location)
- func (l *Library) Get(id borges.RepositoryID, m borges.Mode) (borges.Repository, error)
- func (l *Library) GetOrInit(borges.RepositoryID) (borges.Repository, error)
- func (l *Library) Has(id borges.RepositoryID) (bool, borges.LibraryID, borges.LocationID, error)
- func (l *Library) ID() borges.LibraryID
- func (l *Library) Init(borges.RepositoryID) (borges.Repository, error)
- func (l *Library) Libraries() (borges.LibraryIterator, error)
- func (l *Library) Library(id borges.LibraryID) (borges.Library, error)
- func (l *Library) Location(id borges.LocationID) (borges.Location, error)
- func (l *Library) Locations() (borges.LocationIterator, error)
- func (l *Library) Repositories(mode borges.Mode) (borges.RepositoryIterator, error)
- type LibraryOptions
- type Location
- func (l *Location) Get(id borges.RepositoryID, mode borges.Mode) (borges.Repository, error)
- func (l *Location) GetOrInit(id borges.RepositoryID) (borges.Repository, error)
- func (l *Location) Has(id borges.RepositoryID) (bool, error)
- func (l *Location) ID() borges.LocationID
- func (l *Location) Init(id borges.RepositoryID) (borges.Repository, error)
- func (l *Location) Library() borges.Library
- func (l *Location) Repositories(m borges.Mode) (borges.RepositoryIterator, error)
- func (l *Location) RepositoryPath(id borges.RepositoryID) string
- type LocationIterator
- type LocationOptions
- type Repository
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
AddLibrary adds a Library to this Library.
func (*Library) AddLocation ¶
AddLocation adds a Location to this Library.
func (*Library) Get ¶
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) Has ¶
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) Libraries ¶
Libraries returns a LibraryIterator that iterates through all libraries contained in this Library.
func (*Library) Library ¶
Library returns the Library with the given LibraryID, if a library can't be found ErrLibraryNotExists is returned.
func (*Library) Location ¶
Location returns the a Location with the given ID, if exists, otherwise ErrLocationNotExists is returned.
func (*Library) Locations ¶
Locations returns a LocationIterator that iterates through all locations contained in this Library.
func (*Library) Repositories ¶
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 ¶
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 ¶
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 ¶
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) Library ¶
func (l *Location) Library() borges.Library
Library implements the borges.Location interface.
func (*Location) Repositories ¶
Repositories returns a RepositoryIterator that iterates through all the repositories contained in this Location.
func (*Location) RepositoryPath ¶
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) 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.