git

package
v0.0.0-...-43874bb Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2016 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChecksum       = errors.New("Incorrect checksum")
	ErrObjectNotFound = errors.New("Object not found")
)
View Source
var ErrInvalidDelta = errors.New("invalid delta")
View Source
var ErrPrefixNotMatch = errors.New("Prefix not match")
View Source
var ErrTypeMismatch = errors.New("Error type mismatch")
View Source
var ErrUnknownFormat = errors.New("Unknown format")

Functions

func BranchRef

func BranchRef(name string) string

BranchRef returns full ref name of given branch name.

func TagRef

func TagRef(name string) string

TagRef returns full ref name of given tag name.

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

func (*Blob) Write

func (b *Blob) Write() error

type ByName

type ByName []*TreeEntry

func (ByName) Len

func (z ByName) Len() int

func (ByName) Less

func (z ByName) Less(i, j int) bool

func (ByName) Swap

func (z ByName) Swap(i, j int)

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

func (*Commit) Write

func (c *Commit) Write() error

type Object

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

type ObjectData

type ObjectData interface {
	io.Reader
	Size() int64
}

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 (*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
	// contains filtered or unexported fields
}

func (*Ref) Commit

func (r *Ref) Commit() (*Commit, error)

Commit returns a commit object that the ref points to. It also understand annotated tags. The returned commit object maybe unresolved, it's necessary to call Resolve function before using commit data.

func (*Ref) Delete

func (r *Ref) Delete() error

func (*Ref) Write

func (r *Ref) Write() error

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) Blob

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

func (*Repository) Branches

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

func (*Repository) Commit

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

func (*Repository) FindRef

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

FindRef searches ref that has given name. Both full name and omitted name are accepted like git command.

func (*Repository) Head

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

func (*Repository) NewBlob

func (r *Repository) NewBlob(data ObjectData) *Blob

func (*Repository) NewCommit

func (r *Repository) NewCommit(tree *Tree, parents []*Commit, author, committer *User, msg string) *Commit

func (*Repository) NewRef

func (r *Repository) NewRef(name string, id SHA1) *Ref

func (*Repository) NewTag

func (r *Repository) NewTag(name string, obj Object, tagger *User, msg string) *Tag

func (*Repository) NewTree

func (r *Repository) NewTree() *Tree

func (*Repository) Object

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

func (*Repository) Ref

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

Ref loads ref that has given name. It only accepts full name. If it's not certain about what kind of refs, FindRef maybe helpful.

func (*Repository) Resolve

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

func (*Repository) Tag

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

func (Repository) Tags

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

func (*Repository) Tree

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

type SHA1

type SHA1 [20]byte

func NewSHA1

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

func SHA1FromBytes

func SHA1FromBytes(b []byte) (sha SHA1)

func SHA1FromHex

func SHA1FromHex(b []byte) (sha SHA1)

func SHA1FromHexString

func SHA1FromHexString(s string) SHA1

func (SHA1) Bytes

func (b SHA1) Bytes() []byte

func (SHA1) Compare

func (b SHA1) Compare(other SHA1) int

func (SHA1) Empty

func (b SHA1) Empty() bool

func (*SHA1) Fill

func (b *SHA1) Fill(r io.Reader) error

func (SHA1) String

func (b SHA1) String() string

type SparseObject

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

func (*SparseObject) Blob

func (s *SparseObject) Blob() (*Blob, error)

func (*SparseObject) Commit

func (s *SparseObject) Commit() (*Commit, error)

func (*SparseObject) Resolve

func (s *SparseObject) Resolve() (Object, error)

func (*SparseObject) SHA1

func (s *SparseObject) SHA1() SHA1

func (*SparseObject) Tag

func (s *SparseObject) Tag() (*Tag, error)

func (*SparseObject) Tree

func (s *SparseObject) Tree() (*Tree, error)

func (*SparseObject) Write

func (s *SparseObject) Write() error

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

func (*Tag) Write

func (t *Tag) Write() error

type Tree

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

func (*Tree) Add

func (t *Tree) Add(path string, obj Object, mode TreeEntryMode) error

func (*Tree) Find

func (t *Tree) Find(path string) (*SparseObject, TreeEntryMode, error)

func (*Tree) FindBlob

func (t *Tree) FindBlob(path string) (*Blob, TreeEntryMode, error)

func (*Tree) FindTree

func (t *Tree) FindTree(path string) (*Tree, TreeEntryMode, error)

func (*Tree) Parse

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

func (*Tree) Remove

func (t *Tree) Remove(path string) 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

func (*Tree) Write

func (t *Tree) Write() error

type TreeEntry

type TreeEntry struct {
	Mode   TreeEntryMode
	Name   string
	Object *SparseObject
}

func (*TreeEntry) Size

func (t *TreeEntry) Size() int

type TreeEntryMode

type TreeEntryMode uint32
const (
	ModeTree    TreeEntryMode = 0040000
	ModeFile    TreeEntryMode = 0100644
	ModeFileEx  TreeEntryMode = 0100755
	ModeSymlink TreeEntryMode = 0120000
)

func (TreeEntryMode) String

func (m TreeEntryMode) String() string

type User

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

func NewUser

func NewUser(name, email string) *User

func (*User) String

func (u *User) String() string

Jump to

Keyboard shortcuts

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