core

package
v3.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package core implement the core interfaces and structs used by go-git

Index

Constants

This section is empty.

Variables

View Source
var (
	ObjectNotFoundErr = errors.New("object not found")
	// ErrInvalidType is returned when an invalid object type is provided.
	ErrInvalidType = errors.New("invalid object type")
)

Functions

This section is empty.

Types

type Hash

type Hash [20]byte

Hash SHA1 hased content

var ZeroHash Hash

ZeroHash is Hash with value zero

func ComputeHash

func ComputeHash(t ObjectType, content []byte) Hash

ComputeHash compute the hash for a given ObjectType and content

func NewHash

func NewHash(s string) Hash

NewHash return a new Hash from a hexadecimal hash representation

func (Hash) IsZero

func (h Hash) IsZero() bool

func (Hash) String

func (h Hash) String() string

type Hasher

type Hasher struct {
	hash.Hash
}

func NewHasher

func NewHasher(t ObjectType, size int64) Hasher

func (Hasher) Sum

func (h Hasher) Sum() (hash Hash)

type Object

type Object interface {
	Hash() Hash
	Type() ObjectType
	SetType(ObjectType)
	Size() int64
	SetSize(int64)
	Reader() (ObjectReader, error)
	Writer() (ObjectWriter, error)
}

Object is a generic representation of any git object

type ObjectIter

type ObjectIter interface {
	Next() (Object, error)
	Close()
}

ObjectIter is a generic closable interface for iterating over objects.

type ObjectLookupIter

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

ObjectLookupIter implements ObjectIter. It iterates over a series of object hashes and yields their associated objects by retrieving each one from object storage. The retrievals are lazy and only occur when the iterator moves forward with a call to Next().

The ObjectLookupIter must be closed with a call to Close() when it is no longer needed.

func NewObjectLookupIter

func NewObjectLookupIter(storage ObjectStorage, series []Hash) *ObjectLookupIter

NewObjectLookupIter returns an object iterator given an object storage and a slice of object hashes.

func (*ObjectLookupIter) Close

func (iter *ObjectLookupIter) Close()

Close releases any resources used by the iterator.

func (*ObjectLookupIter) Next

func (iter *ObjectLookupIter) Next() (Object, error)

Next returns the next object from the iterator. If the iterator has reached the end it will return io.EOF as an error. If the object can't be found in the object storage, it will return ObjectNotFoundErr as an error. If the object is retreieved successfully error will be nil.

type ObjectReader

type ObjectReader io.ReadCloser

ObjectReader is a generic representation of an object reader.

ObjectReader implements io.ReadCloser. Close should be called when finished with it.

type ObjectSliceIter

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

ObjectSliceIter implements ObjectIter. It iterates over a series of objects stored in a slice and yields each one in turn when Next() is called.

The ObjectSliceIter must be closed with a call to Close() when it is no longer needed.

func NewObjectSliceIter

func NewObjectSliceIter(series []Object) *ObjectSliceIter

NewObjectSliceIter returns an object iterator for the given slice of objects.

func (*ObjectSliceIter) Close

func (iter *ObjectSliceIter) Close()

Close releases any resources used by the iterator.

func (*ObjectSliceIter) Next

func (iter *ObjectSliceIter) Next() (Object, error)

Next returns the next object from the iterator. If the iterator has reached the end it will return io.EOF as an error. If the object is retreieved successfully error will be nil.

type ObjectStorage

type ObjectStorage interface {
	New() (Object, error)
	Set(Object) (Hash, error)
	Get(Hash) (Object, error)
	Iter(ObjectType) ObjectIter
}

ObjectStorage generic storage of objects

type ObjectType

type ObjectType int8

ObjectType internal object type's

const (
	CommitObject   ObjectType = 1
	TreeObject     ObjectType = 2
	BlobObject     ObjectType = 3
	TagObject      ObjectType = 4
	OFSDeltaObject ObjectType = 6
	REFDeltaObject ObjectType = 7
)

func ParseObjectType

func ParseObjectType(value string) (typ ObjectType, err error)

ParseObjectType parses a string representation of ObjectType. It returns an error on parse failure.

func (ObjectType) Bytes

func (t ObjectType) Bytes() []byte

func (ObjectType) String

func (t ObjectType) String() string

func (ObjectType) Valid

func (t ObjectType) Valid() bool

Valid returns true if t is a valid ObjectType.

type ObjectWriter

type ObjectWriter io.WriteCloser

ObjectWriter is a generic representation of an object writer.

ObjectWriter implements io.WriterCloser. Close should be called when finished with it.

type PermanentError

type PermanentError struct {
	Err error
}

func NewPermanentError

func NewPermanentError(err error) *PermanentError

func (*PermanentError) Error

func (e *PermanentError) Error() string

type UnexpectedError

type UnexpectedError struct {
	Err error
}

func NewUnexpectedError

func NewUnexpectedError(err error) *UnexpectedError

func (*UnexpectedError) Error

func (e *UnexpectedError) Error() string

Jump to

Keyboard shortcuts

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