git

package module
v0.0.0-...-efb94e6 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2015 License: MIT Imports: 16 Imported by: 0

README

gogit

A pure Go Git library.

This package provides set of tools to handle a git repository directly from Go program without external git command.

Highlighted features are:

  • Handle a git repository including a bare repository.
  • Get a commit, tree, blob or tag object from a repository.
  • Parse pack files and pack index v2 files (pack index v1 not yet supported).
  • Parse packed-refs file.
  • Objects and refs are seamlessly resolved whether it's packed or not.
  • Implemented by only Go, no need for cgo or external git command.

Currently, it supports read access only. But supporting write access is planed.

This is just worked but in early development stage, breaking changes maybe introduced suddenly. So please consider to use vendoring.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDelta = errors.New("invalid delta")
View Source
var ErrObjectNotFound = errors.New("Object not found")
View Source
var ErrPrefixNotMatch = errors.New("Prefix not match")
View Source
var ErrUnknownFormat = errors.New("Unknown format")

Functions

This section is empty.

Types

type Blob

type Blob struct {
	Data []byte
	// contains filtered or unexported fields
}

func (*Blob) Parse

func (b *Blob) Parse(data []byte) error

func (*Blob) Resolve

func (b *Blob) Resolve() error

func (*Blob) Resolved

func (b *Blob) Resolved() bool

func (*Blob) SHA1

func (b *Blob) SHA1() SHA1

type CRC32

type CRC32 [4]byte

type Commit

type Commit struct {
	Tree      *Tree
	Parents   []*Commit
	Author    *User
	Committer *User
	Data      []byte
	// contains filtered or unexported fields
}

func (*Commit) IsMerge

func (c *Commit) IsMerge() bool

func (*Commit) IsRoot

func (c *Commit) IsRoot() bool

func (*Commit) Parse

func (c *Commit) Parse(data []byte) error

func (*Commit) Resolve

func (c *Commit) Resolve() error

func (*Commit) Resolved

func (c *Commit) Resolved() bool

func (*Commit) SHA1

func (c *Commit) SHA1() SHA1

type Object

type Object interface {
	SHA1() SHA1
	Parse([]byte) error
	Resolve() error
	Resolved() bool
}

type Pack

type Pack struct {
	PackHeader
	// contains filtered or unexported fields
}

func OpenPack

func OpenPack(path string) (*Pack, error)

func (*Pack) Close

func (p *Pack) Close() error

func (*Pack) Object

func (p *Pack) Object(id SHA1, repo *Repository) (Object, error)

type PackHeader

type PackHeader struct {
	Magic   [4]byte
	Version uint32
	Total   uint32
}

type PackIndexEntry

type PackIndexEntry struct {
	ID     SHA1
	Offset int64
}

type PackIndexV2

type PackIndexV2 struct {
	PackIndexV2Header
	Objects       []SHA1
	CRC32s        []CRC32
	Offsets       []uint32
	LargeOffsets  []uint64
	PackFileHash  SHA1
	PackIndexHash SHA1
}

func OpenPackIndex

func OpenPackIndex(path string) (*PackIndexV2, error)

func (*PackIndexV2) Entry

func (idx *PackIndexV2) Entry(id SHA1) *PackIndexEntry

func (*PackIndexV2) Parse

func (idx *PackIndexV2) Parse(r io.Reader) (err error)

type PackIndexV2Header

type PackIndexV2Header struct {
	Magic   [4]byte
	Version uint32
	Fanout  [256]uint32
}

type PackedRefs

type PackedRefs struct {
	Path string
	Err  error
	// contains filtered or unexported fields
}

func OpenPackedRefs

func OpenPackedRefs(root string) *PackedRefs

func (*PackedRefs) Parse

func (p *PackedRefs) Parse() error

func (*PackedRefs) Ref

func (p *PackedRefs) Ref(name string) *Ref

func (*PackedRefs) Refs

func (p *PackedRefs) Refs(prefix string) []*Ref

type Ref

type Ref struct {
	Name   string
	SHA1   SHA1
	Commit *SHA1
}

type Refs

type Refs []*Ref

type Repository

type Repository struct {
	Path string
	Bare bool
	// contains filtered or unexported fields
}

func Open

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

func (*Repository) Branches

func (r *Repository) Branches() []*Ref

func (*Repository) Head

func (r *Repository) Head() (*Ref, error)

func (*Repository) Object

func (r *Repository) Object(id SHA1) (Object, error)

func (*Repository) Ref

func (r *Repository) Ref(name string) (*Ref, error)

func (*Repository) Resolve

func (r *Repository) Resolve(obj Object) error

func (Repository) Tags

func (r Repository) Tags() []*Ref

type SHA1

type SHA1 [20]byte

func NewSHA1

func NewSHA1(s string) (sha SHA1, err error)

func SHA1FromString

func SHA1FromString(s string) SHA1

func (SHA1) Compare

func (b SHA1) Compare(other SHA1) int

func (SHA1) String

func (b SHA1) String() string

type Tag

type Tag struct {
	Object Object
	Name   string
	Tagger *User
	Data   []byte
	// contains filtered or unexported fields
}

func (*Tag) Parse

func (t *Tag) Parse(data []byte) error

func (*Tag) Resolve

func (t *Tag) Resolve() error

func (*Tag) Resolved

func (t *Tag) Resolved() bool

func (*Tag) SHA1

func (t *Tag) SHA1() SHA1

type Tree

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

func (*Tree) Find

func (t *Tree) Find(path string) (Object, error)

func (*Tree) Parse

func (t *Tree) Parse(data []byte) error

func (*Tree) Resolve

func (t *Tree) Resolve() error

func (*Tree) Resolved

func (t *Tree) Resolved() bool

func (*Tree) SHA1

func (t *Tree) SHA1() SHA1

type TreeEntry

type TreeEntry struct {
	Mode   int
	Name   string
	Object Object
}

type User

type User struct {
	Name  string
	Email string
	Date  time.Time
}

Jump to

Keyboard shortcuts

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