gogit: github.com/speedata/gogit Index | Files

package gogit

import "github.com/speedata/gogit"

Read access to a git repository.

The api is inspired but not compatible with the Go bindings of libgit2 (git2go).

Index

Package Files

blob.go commit.go doc.go oid.go reference.go repository.go signature.go tag.go tree.go

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.

type Blob Uses

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

func (*Blob) Contents Uses

func (b *Blob) Contents() []byte

func (*Blob) Size Uses

func (b *Blob) Size() int

type Commit Uses

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) Id Uses

func (ci *Commit) Id() *Oid

Get the id of the commit.

func (*Commit) Message Uses

func (ci *Commit) Message() string

Return the commit message. Same as retrieving CommitMessage directly.

func (*Commit) Parent Uses

func (ci *Commit) Parent(n int) *Commit

Return parent number n (0-based index)

func (*Commit) ParentCount Uses

func (ci *Commit) ParentCount() int

Return the number of parents of the commit. 0 if this is the root commit, otherwise 1,2,...

func (*Commit) ParentId Uses

func (ci *Commit) ParentId(n int) *Oid

Return oid of the parent number n (0-based index). Return nil if no such parent exists.

func (*Commit) TreeId Uses

func (ci *Commit) TreeId() *Oid

Return oid of the (root) tree of this commit.

type Object Uses

type Object struct {
    Type ObjectType
    Oid  *Oid
}

type ObjectType Uses

type ObjectType int

Who am I?

const (
    ObjectCommit ObjectType = 0x10
    ObjectTree   ObjectType = 0x20
    ObjectBlob   ObjectType = 0x30
    ObjectTag    ObjectType = 0x40
)

func (ObjectType) String Uses

func (t ObjectType) String() string

type Oid Uses

type Oid struct {
    Bytes SHA1
}

Oid is the representation of a sha1-string

func NewOid Uses

func NewOid(b []byte) (*Oid, error)

Create a new Oid from a 20 byte slice.

func NewOidFromArray Uses

func NewOidFromArray(a SHA1) *Oid

Create a new Oid from a 20 byte array

func NewOidFromByteString Uses

func NewOidFromByteString(b []byte) (*Oid, error)

Create a new Oid from a 40 byte hex-encoded slice.

func NewOidFromString Uses

func NewOidFromString(sha1 string) (*Oid, error)

Create a new Oid from a Sha1 string of length 40. In performance-sensitive paths, use NewOidFromByteString.

func (*Oid) Equal Uses

func (o *Oid) Equal(oid2 *Oid) bool

Equal reports whether o and oid2 have the same sha1.

func (*Oid) String Uses

func (o *Oid) String() string

Return string (hex) representation of the Oid

type Reference Uses

type Reference struct {
    Name string
    Oid  *Oid
    // contains filtered or unexported fields
}

func (*Reference) Target Uses

func (r *Reference) Target() *Oid

For compatibility with git2go. Return Oid from referece (same as getting .Oid directly)

type Repository Uses

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 Uses

func OpenRepository(path string) (*Repository, error)

Open the repository at the given path.

func (*Repository) LookupBlob Uses

func (repos *Repository) LookupBlob(oid *Oid) (*Blob, error)

Find the blob object in the repository.

func (*Repository) LookupCommit Uses

func (repos *Repository) LookupCommit(oid *Oid) (*Commit, error)

Find the commit object in the repository.

func (*Repository) LookupReference Uses

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 Uses

func (repos *Repository) LookupTag(oid *Oid) (*Tag, error)

Find the tag object in the repository.

func (*Repository) LookupTree Uses

func (repos *Repository) LookupTree(oid *Oid) (*Tree, error)

Find the tree object in the repository.

func (*Repository) ObjectSize Uses

func (repos *Repository) ObjectSize(oid *Oid) (int64, error)

Get (inflated) size of an object.

func (*Repository) Type Uses

func (repos *Repository) Type(oid *Oid) (ObjectType, error)

Get the type of an object.

type SHA1 Uses

type SHA1 [20]byte

type Signature Uses

type Signature struct {
    Email string
    Name  string
    When  time.Time
}

Author and Committer information

type Tag Uses

type Tag struct {
    Type     TagType
    Name     string
    Message  string
    TargetId *Oid
    Tagger   *Signature
    // contains filtered or unexported fields
}

type TagType Uses

type TagType int

Who am I?

const (
    TagCommit TagType = iota
)

type Tree Uses

type Tree struct {
    TreeEntries []*TreeEntry
    Oid         *Oid
    // contains filtered or unexported fields
}

A tree is a flat directory listing.

func (*Tree) EntryByIndex Uses

func (t *Tree) EntryByIndex(index int) *TreeEntry

Get the n-th entry of this tree (0 = first entry). You can also access t.TreeEntries[index] directly.

func (*Tree) EntryByName Uses

func (t *Tree) EntryByName(name string) *TreeEntry

Find the entry in this directory (tree) with the given name.

func (*Tree) EntryCount Uses

func (t *Tree) EntryCount() int

Get the number of entries in the directory (tree). Same as len(t.TreeEntries).

func (*Tree) Walk Uses

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 Uses

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.

type TreeWalkCallback Uses

type TreeWalkCallback func(string, *TreeEntry) int

Package gogit imports 17 packages (graph) and is imported by 3 packages. Updated 2017-05-30. Refresh now. Tools for package owners.