Documentation ¶
Overview ¶
Read access to a git repository.
The api is inspired but not compatible with the Go bindings of libgit2 (git2go).
Index ¶
- Constants
- type Blob
- type Commit
- type Object
- type ObjectType
- type Oid
- type Reference
- type Repository
- func (repos *Repository) LookupBlob(oid *Oid) (*Blob, error)
- func (repos *Repository) LookupCommit(oid *Oid) (*Commit, error)
- func (repos *Repository) LookupReference(name string) (*Reference, error)
- func (repos *Repository) LookupTag(oid *Oid) (*Tag, error)
- func (repos *Repository) LookupTree(oid *Oid) (*Tree, error)
- func (repos *Repository) ObjectSize(oid *Oid) (int64, error)
- func (repos *Repository) Type(oid *Oid) (ObjectType, error)
- type SHA1
- type Signature
- type Tag
- type TagType
- type Tree
- type TreeEntry
- type TreeWalkCallback
Constants ¶
const ( VersionMajor = 0 VersionMinor = 0 VersionPatchlevel = 0 )
Version information: ‹Major›.‹Minor›.‹Patchlevel›
const ( FileModeBlob = 0100644 FileModeBlobExec = 0100755 FileModeSymlink = 0120000 FileModeCommit = 0160000 FileModeTree = 0040000 )
There are only a few file modes in Git. They look like unix file modes, but they can only be one of these.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct { Author *Signature Committer *Signature Oid *Oid // The id of this commit object CommitMessage string Tree *Tree // contains filtered or unexported fields }
func (*Commit) ParentCount ¶
Return the number of parents of the commit. 0 if this is the root commit, otherwise 1,2,...
type Object ¶
type Object struct { Type ObjectType Oid *Oid }
type ObjectType ¶
type ObjectType int
Who am I?
const ( ObjectCommit ObjectType = 0x10 ObjectTree ObjectType = 0x20 ObjectBlob ObjectType = 0x30 ObjectTag ObjectType = 0x40 )
func (ObjectType) String ¶
func (t ObjectType) String() string
type Oid ¶
type Oid struct {
Bytes SHA1
}
Oid is the representation of a sha1-string
func NewOidFromByteString ¶
Create a new Oid from a 40 byte hex-encoded slice.
func NewOidFromString ¶
Create a new Oid from a Sha1 string of length 40. In performance-sensitive paths, use NewOidFromByteString.
type Repository ¶
type Repository struct { Path string // contains filtered or unexported fields }
A Repository is the base of all other actions. If you need to lookup a commit, tree or blob, you do it from here.
func OpenRepository ¶
func OpenRepository(path string) (*Repository, error)
Open the repository at the given path.
func (*Repository) LookupBlob ¶
func (repos *Repository) LookupBlob(oid *Oid) (*Blob, error)
Find the blob object in the repository.
func (*Repository) LookupCommit ¶
func (repos *Repository) LookupCommit(oid *Oid) (*Commit, error)
Find the commit object in the repository.
func (*Repository) LookupReference ¶
func (repos *Repository) LookupReference(name string) (*Reference, error)
A typical Git repository consists of objects (path objects/ in the root directory) and of references to HEAD, branches, tags and such.
func (*Repository) LookupTag ¶
func (repos *Repository) LookupTag(oid *Oid) (*Tag, error)
Find the tag object in the repository.
func (*Repository) LookupTree ¶
func (repos *Repository) LookupTree(oid *Oid) (*Tree, error)
Find the tree object in the repository.
func (*Repository) ObjectSize ¶
func (repos *Repository) ObjectSize(oid *Oid) (int64, error)
Get (inflated) size of an object.
func (*Repository) Type ¶
func (repos *Repository) Type(oid *Oid) (ObjectType, error)
Get the type of an object.
type Tree ¶
A tree is a flat directory listing.
func (*Tree) EntryByIndex ¶
Get the n-th entry of this tree (0 = first entry). You can also access t.TreeEntries[index] directly.
func (*Tree) EntryByName ¶
Find the entry in this directory (tree) with the given name.
func (*Tree) EntryCount ¶
Get the number of entries in the directory (tree). Same as len(t.TreeEntries).
func (*Tree) Walk ¶
func (t *Tree) Walk(callback TreeWalkCallback) error
The entries will be traversed in the specified order, children subtrees will be automatically loaded as required, and the callback will be called once per entry with the current (relative) root for the entry and the entry data itself.
If the callback returns a positive value, the passed entry will be skipped on the traversal (in pre mode). A negative value stops the walk.
Walk will panic() if an error occurs
type TreeEntry ¶
type TreeEntry struct { Filemode int Name string Id *Oid Type ObjectType }
A tree entry is similar to a directory entry (file name, type) in a real file system.