gitfs

package
v1.53.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithReference

func WithReference(ref plumbing.ReferenceName) containers.Option[Options]

WithReference overrides the default reference to main.

Types

type Dir

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

Dir is a representation of a directory found within a filesystem. The contents of the directory can be listed and accessed via the ReadDir method. It is an implementation of fs.File.

func (*Dir) Close

func (d *Dir) Close() error

func (*Dir) Read

func (d *Dir) Read(p []byte) (n int, err error)

func (*Dir) ReadDir

func (d *Dir) ReadDir(n int) (dst []fs.DirEntry, err error)

ReadDir reads the contents of the directory and returns a slice of up to n DirEntry values in directory order. Subsequent calls on the same file will yield further DirEntry values.

If n > 0, ReadDir returns at most n DirEntry structures. In this case, if ReadDir returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is io.EOF. (ReadDir must return io.EOF itself, not an error wrapping io.EOF.)

If n <= 0, ReadDir returns all the DirEntry values from the directory in a single slice. In this case, if ReadDir succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, ReadDir returns the DirEntry list read until that point and a non-nil error.

func (*Dir) Stat

func (d *Dir) Stat() (fs.FileInfo, error)

type DirEntry

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

DirEntry represents an entry within a file system directory. The entry could itself be a directory or another type of file.

func (DirEntry) Info

func (d DirEntry) Info() (fs.FileInfo, error)

Info returns the FileInfo for the file or subdirectory described by the entry. The returned FileInfo may be from the time of the original directory read or from the time of the call to Info. If the file has been removed or renamed since the directory read, Info may return an error satisfying errors.Is(err, ErrNotExist). If the entry denotes a symbolic link, Info reports the information about the link itself, not the link's target.

func (DirEntry) IsDir

func (d DirEntry) IsDir() bool

IsDir reports whether the entry describes a directory.

func (DirEntry) Name

func (d DirEntry) Name() string

Name returns the name of the file (or subdirectory) described by the entry. This name is only the final element of the path (the base name), not the entire path. For example, Name would return "hello.go" not "home/gopher/hello.go".

func (DirEntry) Type

func (d DirEntry) Type() fs.FileMode

Type returns the type bits for the entry. The type bits are a subset of the usual FileMode bits, those returned by the FileMode.Type method.

type FS

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

FS is a filesystem implementation that decorates a git storage implementation and instance of a git tree. FS implements fs.FS and is therefore read-only by design.

func New

func New(logger *zap.Logger, storage storage.Storer, tree *object.Tree) FS

New instantiates and instance of storage which retrieves files from the provided storage.Storer implementation and instance of *object.Tree.

func NewFromRepo

func NewFromRepo(logger *zap.Logger, repo *git.Repository, opts ...containers.Option[Options]) (FS, error)

NewFromRepo is a convenience utility which constructs an instance of FS from the provided git repository. By default the returned FS serves the content from the root tree for the commit at reference HEAD.

func NewFromRepoHash

func NewFromRepoHash(logger *zap.Logger, repo *git.Repository, hash plumbing.Hash) (FS, error)

NewFromRepoHash is a convenience utility which constructs an instance of FS from the provided git repository and hash.

func NewFromRepoHashString

func NewFromRepoHashString(logger *zap.Logger, repo *git.Repository, hash string) (FS, error)

NewFromRepoHash is a convenience utility which constructs an instance of FS from the provided git repository and hash string.

func (FS) Open

func (f FS) Open(name string) (_ fs.File, err error)

Open opens the named file. When Open returns an error, it should be of type *PathError with the Op field set to "open", the Path field set to name, and the Err field describing the problem.

Open should reject attempts to open names that do not satisfy ValidPath(name), returning a *PathError with Err set to ErrInvalid or ErrNotExist.

type File

type File struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

File is a representation of a file which can be read.

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek attempts to seek the embedded read-closer. If the embedded read closer implements seek, then it delegates to that instances implementation. Alternatively, it returns an error signifying that the File cannot be seeked.

func (*File) Stat

func (f *File) Stat() (fs.FileInfo, error)

type FileInfo

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

FileInfo contains metadata about a file including its name, size, mode and last modified timestamp.

func (FileInfo) IsDir

func (f FileInfo) IsDir() bool

func (FileInfo) ModTime

func (f FileInfo) ModTime() time.Time

func (FileInfo) Mode

func (f FileInfo) Mode() fs.FileMode

func (FileInfo) Name

func (f FileInfo) Name() string

func (FileInfo) Size

func (f FileInfo) Size() int64

func (FileInfo) Sys

func (f FileInfo) Sys() any

type Options

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

Options configures call to NewFromRepo.

Jump to

Keyboard shortcuts

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