Documentation
¶
Index ¶
- Constants
- func IsBareRepository(path string) bool
- func IsBranchRef(r Ref) bool
- func IsDeltaObject(ot ObjectType) bool
- func IsStandardObject(ot ObjectType) bool
- type Blob
- type Commit
- type CommitSummary
- type Delta
- func (o *Delta) Close() error
- func (d *Delta) Err() error
- func (d *Delta) NextOp() bool
- func (d *Delta) Op() DeltaOp
- func (d *Delta) Patch(r io.ReadSeeker, w io.Writer) error
- func (o *Delta) Size() int64
- func (d *Delta) SkipOp()
- func (o *Delta) Type() ObjectType
- func (d *Delta) WriteTo(w io.Writer) (int64, error)
- type DeltaOp
- type DeltaOpCode
- type FanOut
- type IDRef
- type Object
- type ObjectType
- type PackFile
- type PackHeader
- type PackIndex
- type Ref
- type Repository
- func (repo *Repository) BranchExists(branch string) (bool, error)
- func (repo *Repository) CommitsForRef(ref string) ([]CommitSummary, error)
- func (repo *Repository) DeleteCollaborator(username string) error
- func (repo *Repository) GetBlobsForCommit(commit *Commit, blobs map[SHA1]*Blob) error
- func (repo *Repository) GetBlobsForTree(tree *Tree, blobs map[SHA1]*Blob) error
- func (repo *Repository) ObjectForPath(root Object, pathstr string) (Object, error)
- func (repo *Repository) OpenObject(id SHA1) (Object, error)
- func (repo *Repository) OpenRef(name string) (Ref, error)
- func (repo *Repository) ReadDescription() string
- func (repo *Repository) Readlink(id SHA1) (string, error)
- func (repo *Repository) WalkRef(refname string, goOn func(SHA1) bool) (map[SHA1]*Commit, error)
- func (repo *Repository) WriteDescription(description string) error
- type SHA1
- type Signature
- type SymbolicRef
- type Tag
- type Tree
- type TreeEntry
Constants ¶
const ( DeltaOpInsert = 1 //insert data from the delta data into dest DeltaOpCopy = 2 //copy data from the original source into dest )
DeltaOpCode values.
const ( ObjCommit = ObjectType(iota) ObjTree ObjBlob ObjTag ObjOFSDelta = ObjectType(0x6) ObjRefDelta = ObjectType(0x7) )
The defined bits match the ones used in the git pack file format.
Variables ¶
This section is empty.
Functions ¶
func IsBareRepository ¶
IsBareRepository checks if path is a bare git repository.
func IsBranchRef ¶
func IsDeltaObject ¶
func IsDeltaObject(ot ObjectType) bool
IsDeltaObject checks if an object is a delta object, i.e. OFSDelta or RefDelta
func IsStandardObject ¶
func IsStandardObject(ot ObjectType) bool
IsStandardObject checks if an object is one of the four common objects such as commit, tree, blob, tag.
Types ¶
type Blob ¶
type Blob struct {
// contains filtered or unexported fields
}
Blob represents a git blob object.
func (*Blob) Type ¶
func (o *Blob) Type() ObjectType
type Commit ¶
type Commit struct { Tree SHA1 Parent []SHA1 Author Signature Committer Signature Message string GPGSig string // contains filtered or unexported fields }
Commit represents one git commit.
func (*Commit) Type ¶
func (o *Commit) Type() ObjectType
type CommitSummary ¶
type CommitSummary struct { Commit string Committer string Author string DateIso string DateRelative string Subject string Changes []string }
CommitSummary represents a subset of information from a git commit.
type Delta ¶
type Delta struct { BaseRef SHA1 BaseOff int64 SizeSource int64 SizeTarget int64 // contains filtered or unexported fields }
Delta represents a git delta representation. Either BaseRef or BaseOff are valid fields, depending on its Type().
func (*Delta) NextOp ¶
NextOp reads the next DeltaOp from the delta data stream. Returns false when there are no operations left or on error; use Err() to decide between the two cases.
func (*Delta) SkipOp ¶
func (d *Delta) SkipOp()
SkipOp prepares the delta stream to move to the next operation without actually carrying out the delta operation. Useful for printing the delta stream.
func (*Delta) Type ¶
func (o *Delta) Type() ObjectType
type DeltaOp ¶
type DeltaOp struct { Op DeltaOpCode Size int64 Offset int64 }
DeltaOp represents the delta compression operation. Offset is only valid for DeltaOpCopy operations.
type DeltaOpCode ¶
type DeltaOpCode byte
DeltaOpCode is the operation code for delta compression instruction set.
type FanOut ¶
type FanOut [256]uint32
FanOut table where the "N-th entry of this table records the number of objects in the corresponding pack, the first byte of whose object name is less than or equal to N.
type IDRef ¶
type IDRef struct {
// contains filtered or unexported fields
}
IDRef is a reference that points via a sha1 directly to a git object
func (*IDRef) Repo ¶
func (r *IDRef) Repo() *Repository
type Object ¶
Object represents a git object. It has information common to all git objects, like their type and their size. Also, all git objects should be closed via Close().
type ObjectType ¶
type ObjectType byte
ObjectType is to the git object type
func ParseObjectType ¶
func ParseObjectType(s string) (ObjectType, error)
ParseObjectType takes a string and converts it to the corresponding ObjectType or error if the string doesn't match any type.
func (ObjectType) String ¶
func (ot ObjectType) String() string
type PackFile ¶
PackFile is git pack file with the actual data in it. It should normally not be used directly.
func OpenPackFile ¶
OpenPackFile opens the git pack file at the given path It will check the pack file header and version. Currently only version 2 is supported. NB: This is low-level API and should most likely not be used directly.
type PackHeader ¶
PackHeader stores version and number of objects in the packfile all data is in network-byte order (big-endian)
type PackIndex ¶
type PackIndex struct { *os.File Version uint32 FO FanOut // contains filtered or unexported fields }
PackIndex represents the git pack file index. It is the main object to use for opening objects contained in packfiles vai OpenObject
func PackIndexOpen ¶
PackIndexOpen opens the git pack file with the given path. The ".idx" if missing will be appended.
func (*PackIndex) FindOffset ¶
FindOffset tries to find object with the id target and if if found returns the offset of the object in the pack file. Returns an error that can be detected by os.IsNotExist if the object could not be found.
func (*PackIndex) OpenObject ¶
OpenObject will try to find the object with the given id in it is index and then reach out to its corresponding pack file to open the actual git Object. If the object cannot be found it will return an error the can be detected via os.IsNotExist() Delta objects will returned as such and not be resolved.
func (*PackIndex) OpenPackFile ¶
OpenPackFile opens the corresponding pack file.
func (*PackIndex) ReadOffset ¶
ReadOffset returns the offset in the pack file of the object at position pos in the FanOut table.
type Repository ¶
type Repository struct {
Path string
}
Repository represents an on disk git repository.
func DiscoverRepository ¶
func DiscoverRepository() (*Repository, error)
DiscoverRepository returns the git repository that contains the current working directory, or and error if the current working dir does not lie inside one.
func InitBareRepository ¶
func InitBareRepository(path string) (*Repository, error)
InitBareRepository creates a bare git repository at path.
func OpenRepository ¶
func OpenRepository(path string) (*Repository, error)
OpenRepository opens the repository at path. Currently verifies that it is a (bare) repository and returns an error if the check fails.
func (*Repository) BranchExists ¶
func (repo *Repository) BranchExists(branch string) (bool, error)
BranchExists runs the "git branch <branchname> --list" command. It will return an error, if the command fails, true, if the result is not empty and false otherwise.
func (*Repository) CommitsForRef ¶
func (repo *Repository) CommitsForRef(ref string) ([]CommitSummary, error)
CommitsForRef executes a custom git log command for the specified ref of the associated git repository and returns the resulting byte array.
func (*Repository) DeleteCollaborator ¶
func (repo *Repository) DeleteCollaborator(username string) error
DeleteCollaborator removes a collaborator file from the repositories sharing folder.
func (*Repository) GetBlobsForCommit ¶
func (repo *Repository) GetBlobsForCommit(commit *Commit, blobs map[SHA1]*Blob) error
func (*Repository) GetBlobsForTree ¶
func (repo *Repository) GetBlobsForTree(tree *Tree, blobs map[SHA1]*Blob) error
func (*Repository) ObjectForPath ¶
func (repo *Repository) ObjectForPath(root Object, pathstr string) (Object, error)
ObjectForPath will resolve the path to an object for the file tree starting in the node root. The root object can be either a Commit, Tree or Tag.
func (*Repository) OpenObject ¶
func (repo *Repository) OpenObject(id SHA1) (Object, error)
OpenObject returns the git object for a give id (SHA1).
func (*Repository) OpenRef ¶
func (repo *Repository) OpenRef(name string) (Ref, error)
OpenRef returns the Ref with the given name or an error if either no maching could be found or in case the match was not unique.
func (*Repository) ReadDescription ¶
func (repo *Repository) ReadDescription() string
ReadDescription returns the contents of the description file.
func (*Repository) Readlink ¶
func (repo *Repository) Readlink(id SHA1) (string, error)
Readlink returns the destination of a symbilc link blob object
func (*Repository) WriteDescription ¶
func (repo *Repository) WriteDescription(description string) error
WriteDescription writes the contents of the description file.
type SHA1 ¶
type SHA1 [20]byte
SHA1 is the object identifying checksum of the object data
type Signature ¶
Signature is a combination of who (Name, Email) and when (Date, Offset). Used by Commit, Tag to link an action (committer, author, tagger, ...) with a person in a point in time.
type SymbolicRef ¶
type SymbolicRef struct { Symbol string // contains filtered or unexported fields }
SymbolicRef is a reference that points to another reference
func (*SymbolicRef) Repo ¶
func (r *SymbolicRef) Repo() *Repository
func (*SymbolicRef) Resolve ¶
func (r *SymbolicRef) Resolve() (SHA1, error)
Resolve will resolve the symbolic reference into an object id.
type Tag ¶
type Tag struct { Object SHA1 ObjType ObjectType Tag string Tagger Signature Message string GPGSig string // contains filtered or unexported fields }
Tag represents a git tag object.
func (*Tag) Type ¶
func (o *Tag) Type() ObjectType
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree represents the git tree object.
func (*Tree) Next ¶
Next advances the pointer to the next TreeEntry within the Tree object. Returns false if it was pointing to the last element (EOF condition), or if there was an error while advacing. Use Err() to resolve between the to conditions.
func (*Tree) Type ¶
func (o *Tree) Type() ObjectType