object

package
v0.0.0-...-dc8f43e Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(data []byte) ([]byte, error)

func Decompress

func Decompress(data []byte) ([]byte, error)

func HashObject

func HashObject(data []byte) string

Types

type Author

type Author struct {
	Name  string
	Email string
	Time  time.Time
}

func (Author) String

func (a Author) String() string

type Blob

type Blob struct {
	Content []byte
}

func NewBlob

func NewBlob(content []byte) *Blob

func (*Blob) Hash

func (b *Blob) Hash() string

func (*Blob) Serialize

func (b *Blob) Serialize() ([]byte, error)

func (*Blob) Size

func (b *Blob) Size() int64

func (*Blob) Type

func (b *Blob) Type() Type

type Commit

type Commit struct {
	TreeHash   string
	ParentHash string
	Author     Author
	Committer  Author
	Message    string
}

func NewCommit

func NewCommit(treeHash string, author Author, message string) *Commit

func (*Commit) Hash

func (c *Commit) Hash() string

func (*Commit) Serialize

func (c *Commit) Serialize() ([]byte, error)

func (*Commit) SetParent

func (c *Commit) SetParent(parentHash string)

func (*Commit) Size

func (c *Commit) Size() int64

func (*Commit) Type

func (c *Commit) Type() Type

type Object

type Object interface {
	Type() Type
	Size() int64
	Hash() string
	Serialize() ([]byte, error)
}

func Deserialize

func Deserialize(data []byte) (Object, error)

Deserialize creates an object from serialized data

func ParseObject

func ParseObject(data []byte) (Object, error)

type Tag

type Tag struct {
	ObjectHash string
	ObjectType Type
	TagName    string
	Tagger     Author
	Message    string
}

func NewTag

func NewTag(objectHash string, objectType Type, tagName string, tagger Author, message string) *Tag

func (*Tag) Hash

func (t *Tag) Hash() string

func (*Tag) Serialize

func (t *Tag) Serialize() ([]byte, error)

func (*Tag) Size

func (t *Tag) Size() int64

func (*Tag) Type

func (t *Tag) Type() Type

type Tree

type Tree struct {
	Entries []TreeEntry
}

func NewTree

func NewTree() *Tree

func (*Tree) AddEntry

func (t *Tree) AddEntry(mode, name, hash string)

func (*Tree) Hash

func (t *Tree) Hash() string

func (*Tree) Serialize

func (t *Tree) Serialize() ([]byte, error)

func (*Tree) Size

func (t *Tree) Size() int64

func (*Tree) Type

func (t *Tree) Type() Type

type TreeEntry

type TreeEntry struct {
	Mode string
	Name string
	Hash string
}

type Type

type Type string
const (
	TypeBlob   Type = "blob"
	TypeTree   Type = "tree"
	TypeCommit Type = "commit"
	TypeTag    Type = "tag"
)

Jump to

Keyboard shortcuts

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