git package - github.com/Nivl/git-go - Go Packages

Package git contains methods to deal with git internals

This section is empty.

View Source

var (
	ErrRepositoryNotExist           = errors.New("repository does not exist")
	ErrRepositoryUnsupportedVersion = errors.New("repository nor supported")
	ErrTagNotFound                  = errors.New("tag not found")
	ErrTagExists                    = errors.New("tag already exists")
	ErrNotADirectory                = errors.New("not a directory")
	ErrInvalidBranchName            = errors.New("invalid branch name")
)

List of errors returned by the Repository struct

This section is empty.

InitOptions contains all the optional data used to initialized a repository

OpenOptions contains all the optional data used to open a repository

Repository represent a git repository A Git repository is the .git/ folder inside a project. This repository tracks all changes made to files in your project, building a history over time. https://blog.axosoft.com/learning-git-repository/

OpenRepository loads an existing git repository by reading its config file, and returns a Repository instance

This assumes: - The repo is not bare (see WithOptions) - We're not interested in env vars (see WithParams) - The git dir is in the working tree under .git

func OpenRepositoryWithOptions(rootPath string, opts OpenOptions) (r *Repository, err error)

OpenRepositoryWithOptions loads an existing git repository by reading its config file, and returns a Repository instance

This assumes: - We're not interested in env vars (see WithParams) - The git dir is in the working tree under .git

OpenRepositoryWithParams loads an existing git repository by reading its config file, and returns a Repository instance

This method makes no assumptions

Blob returns the blob matching the given ID This method will always work as long as the OID points to a valid object. Calling Blob with a commit OID, will return the raw data of the commit.

Close frees the resources used by the repository

Commit returns the commit matching the given SHA

IsBare returns whether the repo is bare or not. A bare repo doesn't have a workign tree

NewBlob creates, stores, and returns a new Blob object

NewCommit creates, stores, and returns a new Commit object The head of the reference $refname will be updated to this new commit. An empty refName will create a detached (loose) commit If the reference doesn't exists, it will be created

NewDetachedCommit creates, stores, and returns a new Commit object not attached to any reference

NewLightweightTag creates, stores, and returns a lightweight tag

NewReference creates, stores, and returns a new reference If the reference already exists, it will be overwritten

NewReferenceSafe creates, stores, and returns a new reference If the reference already exists, the method will fail

NewSymbolicReference creates, stores, and returns a new symbolic reference If the reference already exists, it will be overwritten

NewSymbolicReferenceSafe creates, stores, and returns a new symbolic reference. If the reference already exists, the method will fail

NewTag creates, stores, and returns a new annoted tag

func (r *Repository) NewTreeBuilder() *TreeBuilder

NewTreeBuilder create a new empty tree builder

NewTreeBuilderFromTree create a new tree builder containing the entries of another tree

Object returns the object matching the given ID

Reference returns the reference matching the given name

Tag returns the reference for the given tag To know if the tag is annoted or lightweight, call repo.GetObject() on the reference's target ad make sure that the returned object is not a tag with the same name (note that it's technically possible for a tag to target another tag)

Tree returns the tree matching the given SHA

TreeBuilder is used to build trees

Insert inserts a new object in a tree

Remove removes an object from tree

Write creates and persists a new Tree object