plumbing

package
v4.0.0-rc8+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

package plumbing implement the core interfaces and structs used by go-git

Index

Constants

This section is empty.

Variables

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

Functions

func HashesSort

func HashesSort(a []Hash)

HashesSort sorts a slice of Hashes in increasing order.

Types

type EncodedObject

type EncodedObject interface {
	Hash() Hash
	Type() ObjectType
	SetType(ObjectType)
	Size() int64
	SetSize(int64)
	Reader() (io.ReadCloser, error)
	Writer() (io.WriteCloser, error)
}

Object is a generic representation of any git object

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 HashSlice

type HashSlice []Hash

HashSlice attaches the methods of sort.Interface to []Hash, sorting in increasing order.

func (HashSlice) Len

func (p HashSlice) Len() int

func (HashSlice) Less

func (p HashSlice) Less(i, j int) bool

func (HashSlice) Swap

func (p HashSlice) Swap(i, j int)

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 MemoryObject

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

MemoryObject on memory Object implementation

func (*MemoryObject) Close

func (o *MemoryObject) Close() error

Close releases any resources consumed by the object when it is acting as a ObjectWriter.

func (*MemoryObject) Hash

func (o *MemoryObject) Hash() Hash

Hash return the object Hash, the hash is calculated on-the-fly the first time is called, the subsequent calls the same Hash is returned even if the type or the content has changed. The Hash is only generated if the size of the content is exactly the Object.Size

func (*MemoryObject) Reader

func (o *MemoryObject) Reader() (io.ReadCloser, error)

Reader returns a ObjectReader used to read the object's content.

func (*MemoryObject) SetSize

func (o *MemoryObject) SetSize(s int64)

SetSize set the object size, a content of the given size should be written afterwards

func (*MemoryObject) SetType

func (o *MemoryObject) SetType(t ObjectType)

SetType sets the ObjectType

func (*MemoryObject) Size

func (o *MemoryObject) Size() int64

Size return the size of the object

func (*MemoryObject) Type

func (o *MemoryObject) Type() ObjectType

Type return the ObjectType

func (*MemoryObject) Write

func (o *MemoryObject) Write(p []byte) (n int, err error)

func (*MemoryObject) Writer

func (o *MemoryObject) Writer() (io.WriteCloser, error)

Writer returns a ObjectWriter used to write the object's content.

type ObjectType

type ObjectType int8

ObjectType internal object type Integer values from 0 to 7 map to those exposed by git. AnyObject is used to represent any from 0 to 7.

const (
	InvalidObject ObjectType = 0
	CommitObject  ObjectType = 1
	TreeObject    ObjectType = 2
	BlobObject    ObjectType = 3
	TagObject     ObjectType = 4
	// 5 reserved for future expansion
	OFSDeltaObject ObjectType = 6
	REFDeltaObject ObjectType = 7

	AnyObject ObjectType = -127
)

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 PermanentError

type PermanentError struct {
	Err error
}

func NewPermanentError

func NewPermanentError(err error) *PermanentError

func (*PermanentError) Error

func (e *PermanentError) Error() string

type Reference

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

Reference is a representation of git reference

func NewHashReference

func NewHashReference(n ReferenceName, h Hash) *Reference

NewHashReference creates a new HashReference reference

func NewReferenceFromStrings

func NewReferenceFromStrings(name, target string) *Reference

NewReferenceFromStrings creates a reference from name and target as string, the resulting reference can be a SymbolicReference or a HashReference base on the target provided

func NewSymbolicReference

func NewSymbolicReference(n, target ReferenceName) *Reference

NewSymbolicReference creates a new SymbolicReference reference

func (*Reference) Hash

func (r *Reference) Hash() Hash

Hash return the hash of a hash reference

func (*Reference) IsBranch

func (r *Reference) IsBranch() bool

IsBranch check if a reference is a branch

func (*Reference) IsNote

func (r *Reference) IsNote() bool

IsNote check if a reference is a note

func (*Reference) IsRemote

func (r *Reference) IsRemote() bool

IsRemote check if a reference is a remote

func (*Reference) IsTag

func (r *Reference) IsTag() bool

IsTag check if a reference is a tag

func (*Reference) Name

func (r *Reference) Name() ReferenceName

Name return the name of a reference

func (*Reference) String

func (r *Reference) String() string

func (*Reference) Strings

func (r *Reference) Strings() [2]string

Strings dump a reference as a [2]string

func (*Reference) Target

func (r *Reference) Target() ReferenceName

Target return the target of a symbolic reference

func (*Reference) Type

func (r *Reference) Type() ReferenceType

Type return the type of a reference

type ReferenceName

type ReferenceName string

ReferenceName reference name's

const (
	HEAD   ReferenceName = "HEAD"
	Master ReferenceName = "refs/heads/master"
)

func (ReferenceName) Short

func (r ReferenceName) Short() string

Short returns the short name of a ReferenceName

func (ReferenceName) String

func (r ReferenceName) String() string

type ReferenceType

type ReferenceType int8

ReferenceType reference type's

const (
	InvalidReference  ReferenceType = 0
	HashReference     ReferenceType = 1
	SymbolicReference ReferenceType = 2
)

type UnexpectedError

type UnexpectedError struct {
	Err error
}

func NewUnexpectedError

func NewUnexpectedError(err error) *UnexpectedError

func (*UnexpectedError) Error

func (e *UnexpectedError) Error() string

Directories

Path Synopsis
format
config
Package config implements decoding/encoding of git config files.
Package config implements decoding/encoding of git config files.
idxfile
Package idxfile implements an encoder and a decoder of idx files
Package idxfile implements an encoder and a decoder of idx files
index
Package index implements an encoder and a decoder of index format files
Package index implements an encoder and a decoder of index format files
packfile
Package packfile implements a encoder/decoder of packfile format
Package packfile implements a encoder/decoder of packfile format
pktline
Package pktline implements reading payloads form pkt-lines and encoding pkt-lines from payloads.
Package pktline implements reading payloads form pkt-lines and encoding pkt-lines from payloads.
protocol
packp/sideband
Package sideband implements a sideband mutiplex/demultiplexer
Package sideband implements a sideband mutiplex/demultiplexer
Package revlist implements functions to walk the objects referenced by a commit history.
Package revlist implements functions to walk the objects referenced by a commit history.
Package transport includes the implementation for different transport protocols.
Package transport includes the implementation for different transport protocols.
git
http
Package http implements a HTTP client for go-git.
Package http implements a HTTP client for go-git.
internal/common
Package common implements the git pack protocol with a pluggable transport.
Package common implements the git pack protocol with a pluggable transport.
server
Package server implements the git server protocol.
Package server implements the git server protocol.
ssh
test
Package test implements common test suite for different transport implementations.
Package test implements common test suite for different transport implementations.

Jump to

Keyboard shortcuts

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