backend

package
v0.0.0-...-2ee2aa9 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package backend contains structs and methods to store and retrieve data from the .git directory

Index

Constants

View Source
const (
	CfgCore                  = "core"
	CfgCoreFormatVersion     = "repositoryformatversion"
	CfgCoreFileMode          = "filemode"
	CfgCoreBare              = "bare"
	CfgCoreLogAllRefUpdate   = "logallrefupdates"
	CfgCoreIgnoreCase        = "ignorecase"
	CfgCorePrecomposeUnicode = "precomposeunicode"
)

.git/Config config keys

Variables

View Source
var WalkStop = errors.New("stop walking") //nolint // the linter expects all errors to start with Err, but since here we're faking an error we don't want that

WalkStop is a fake error used to tell Walk() to stop

Functions

This section is empty.

Types

type Backend

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

Backend is a Backend implementation that uses the filesystem to store data

func New

func New(cfg *config.Config, fs afero.Fs) (*Backend, error)

New returns a new Backend object

func NewFS

func NewFS(cfg *config.Config) (*Backend, error)

NewFS returns a new Backend object using the local FileSystem

func (*Backend) Close

func (b *Backend) Close() (err error)

Close frees the resources used by the Backend This method cannot be called concurrently with other methods

func (*Backend) HasObject

func (b *Backend) HasObject(oid ginternals.Oid) (bool, error)

HasObject returns whether an object exists in the odb This method can be called concurrently

func (*Backend) Init

func (b *Backend) Init(branchName string) error

Init initializes a repository. This method cannot be called concurrently with other methods. Calling this method on an existing repository is safe. It will not overwrite things that are already there, but will add what's missing.

func (*Backend) InitWithOptions

func (b *Backend) InitWithOptions(branchName string, opts InitOptions) error

InitWithOptions initializes a repository using the provided options.

This method cannot be called concurrently with other methods. Calling this method on an existing repository is safe. It will not overwrite things that are already there, but will add what's missing.

func (*Backend) Object

func (b *Backend) Object(oid ginternals.Oid) (*object.Object, error)

Object returns the object that has given oid This method can be called concurrently

func (*Backend) Path

func (b *Backend) Path() string

Path returns the absolute path of the repo

func (*Backend) Reference

func (b *Backend) Reference(name string) (*ginternals.Reference, error)

Reference returns a stored reference from its name ErrRefNotFound is returned if the reference doesn't exists This method can be called concurrently

func (*Backend) WalkLooseObjectIDs

func (b *Backend) WalkLooseObjectIDs(f packfile.OidWalkFunc) (err error)

WalkLooseObjectIDs runs the provided method on all the oids of all the packfiles

func (*Backend) WalkPackedObjectIDs

func (b *Backend) WalkPackedObjectIDs(f packfile.OidWalkFunc) error

WalkPackedObjectIDs runs the provided method on all the oids of all the packfiles

func (*Backend) WalkReferences

func (b *Backend) WalkReferences(f RefWalkFunc) error

WalkReferences runs the provided method on all the references

func (*Backend) WriteObject

func (b *Backend) WriteObject(o *object.Object) (ginternals.Oid, error)

WriteObject adds an object to the odb This method can be called concurrently

func (*Backend) WriteReference

func (b *Backend) WriteReference(ref *ginternals.Reference) error

WriteReference writes the given reference on disk. If the reference already exists it will be overwritten

func (*Backend) WriteReferenceSafe

func (b *Backend) WriteReferenceSafe(ref *ginternals.Reference) error

WriteReferenceSafe writes the given reference on disk. ErrRefExists is returned if the reference already exists

type InitOptions

type InitOptions struct {
	// CreateSymlink will create a .git FILE that will contains a path
	// to the repo.
	CreateSymlink bool
}

InitOptions represents all the options that can be used to create a repository

type RefWalkFunc

type RefWalkFunc = func(ref *ginternals.Reference) error

RefWalkFunc represents a function that will be applied on all references found by Walk()

Jump to

Keyboard shortcuts

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