Documentation ¶
Index ¶
- type Repository
- func (r *Repository) Checkout(hash string) error
- func (r *Repository) Commit(msg string, author *object.Signature) error
- func (r *Repository) CreateFile(filename string, data []byte) error
- func (r *Repository) DirExists(filename string) bool
- func (r *Repository) FileExists(filename string) bool
- func (r *Repository) GetFile(filename string) ([]byte, error)
- func (r *Repository) UpdateFile(filename string, cb func([]byte) ([]byte, error)) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository struct { Repo *git.Repository RepoFS *filesystem.Storage Worktree *git.Worktree WorktreeFS billy.Filesystem }
Repository is a fairly lightweight wrapper designed to attach a worktree to a git repository so we don't have to muck about with the raw git objects.
We keep the worktree separate from the repo so we can still have a bare repo. This also lets us do fun things like keep the worktree in memory if we really want to.
func EnsureRepo ¶
func EnsureRepo(baseFS billy.Filesystem, path string) (*Repository, error)
EnsureRepo will open a repository if it exists and try to create it if it doesn't.
func Open ¶
func Open(baseFS billy.Filesystem, path string) (*Repository, error)
Open will open a repository if it exists.
func (*Repository) Checkout ¶
func (r *Repository) Checkout(hash string) error
Checkout will checkout the given hash to the worktreeFS. If an empty string is given, we checkout master.
func (*Repository) Commit ¶
func (r *Repository) Commit(msg string, author *object.Signature) error
Commit is a convenience method to make working with the worktree a little bit easier.
func (*Repository) CreateFile ¶
func (r *Repository) CreateFile(filename string, data []byte) error
CreateFile is a convenience method to set the contents of a file in the repo and stage it.
func (*Repository) DirExists ¶
func (r *Repository) DirExists(filename string) bool
DirExists returns true if the given path exists and is a directory in the repository worktree.
func (*Repository) FileExists ¶
func (r *Repository) FileExists(filename string) bool
FileExists returns true if the given path exists and is a regular file in the repository worktree.
func (*Repository) GetFile ¶
func (r *Repository) GetFile(filename string) ([]byte, error)
GetFile is a convenience method to get the contents of a file in the repo.
func (*Repository) UpdateFile ¶
UpdateFile is a convenience method to get the contents of a file, pass it to a callback, write the contents back to the file if no error was returned, and stage the file.