object

package
v0.0.0-...-f32120d Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

don't do go generate ./... //go:generate stringer -type=ObjectType

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGitObjectDataCorruptted = errors.New("Git object data corruptted.")
	ErrInvalidObject           = errors.New("Invalidate Object.")
)

Functions

func DumpGitObject

func DumpGitObject(r io.Reader, w io.Writer)

Dump object in .git repository

Types

type Blob

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

Blob object, implements Interface TreeEntry{ Object, fs.DirEntry}

func EmptyBlob

func EmptyBlob() *Blob

func GitObjectToBlob

func GitObjectToBlob(g *GitObject) *Blob

func NewBlob

func NewBlob(oid common.Hash, content []byte) *Blob

func (*Blob) Content

func (b *Blob) Content() string

func (*Blob) FromGitObject

func (b *Blob) FromGitObject(g *GitObject)

func (*Blob) Hash

func (b *Blob) Hash() common.Hash

func (*Blob) Id

func (b *Blob) Id() common.Hash

func (*Blob) Kind

func (b *Blob) Kind() ObjectKind

type Commit

type Commit struct {
	TreePair
	// contains filtered or unexported fields
}

func EmptyCommit

func EmptyCommit() *Commit

func GitObjectToCommit

func GitObjectToCommit(g *GitObject) *Commit

GitObject ==> Tree,fitll Tree using GotObject from repository

func NewCommit

func NewCommit(oid common.Hash, treeId common.Hash, parents []common.Hash, author string, committer string, message string) *Commit

func (*Commit) Content

func (c *Commit) Content() string

TODO: output with format interface

func (*Commit) Hash

func (c *Commit) Hash() common.Hash

func (*Commit) Id

func (c *Commit) Id() common.Hash

func (*Commit) Kind

func (c *Commit) Kind() ObjectKind

func (*Commit) Parents

func (c *Commit) Parents() []common.Hash

func (*Commit) ToGitObject

func (c *Commit) ToGitObject() *GitObject

func (*Commit) Tree

func (c *Commit) Tree() common.Hash

type GitObject

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

GitObject, unmodifiable object

func Load

func Load(r io.Reader, oid common.Hash) (*GitObject, error)

Load GitObject from stream (git repository)

func NewGitObject

func NewGitObject(t ObjectKind, content []byte) *GitObject

func (*GitObject) Content

func (g *GitObject) Content() string

func (*GitObject) Hash

func (g *GitObject) Hash() common.Hash

func (*GitObject) Id

func (g *GitObject) Id() common.Hash

func (*GitObject) Kind

func (g *GitObject) Kind() ObjectKind

func (*GitObject) Save

func (g *GitObject) Save(w io.Writer) error

Save GitObject to stream (git repository)

func (*GitObject) Size

func (g *GitObject) Size() int64

type GitObjectInfo

type GitObjectInfo struct {
}

func (*GitObjectInfo) IsDir

func (g *GitObjectInfo) IsDir() bool

func (*GitObjectInfo) ModTime

func (g *GitObjectInfo) ModTime() time.Time

func (*GitObjectInfo) Mode

func (g *GitObjectInfo) Mode() fs.FileMode

func (*GitObjectInfo) Name

func (g *GitObjectInfo) Name() string

func (*GitObjectInfo) Size

func (g *GitObjectInfo) Size() int64

func (*GitObjectInfo) Sys

func (g *GitObjectInfo) Sys() any

type Object

type Object interface {
	Id() common.Hash
	Kind() ObjectKind

	Content() string
}

type ObjectKind

type ObjectKind byte
const (
	Kind_Blob ObjectKind = iota
	Kind_Tree
	Kind_Commit
	Kind_Tag
	Kind_Unknow
)

func ObjectKindFromFilemode

func ObjectKindFromFilemode(fm common.FileMode) ObjectKind

func ParseObjectKind

func ParseObjectKind(kind string) ObjectKind

func (ObjectKind) String

func (t ObjectKind) String() string

type Queue

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

func NewQueue

func NewQueue() *Queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() *Tree

func (*Queue) Enqueue

func (q *Queue) Enqueue(t *Tree)

type Tag

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

func EmptyTag

func EmptyTag() *Tag

func NewTag

func NewTag(oid common.Hash, refObject common.Hash, refType ObjectKind, tagger string) *Tag

func (*Tag) Content

func (c *Tag) Content() string

TODO: output with format interface

func (*Tag) FromGitObject

func (c *Tag) FromGitObject(g *GitObject)

func (*Tag) Id

func (c *Tag) Id() common.Hash

func (*Tag) Object

func (c *Tag) Object() common.Hash

func (*Tag) Tagger

func (c *Tag) Tagger() string

func (*Tag) ToGitObject

func (c *Tag) ToGitObject() *GitObject

func (*Tag) Type

func (c *Tag) Type() ObjectKind

type Tree

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

Tree implements Object interface

func EmptyTree

func EmptyTree() *Tree

func GitObjectToTree

func GitObjectToTree(g *GitObject) *Tree

GitObject ==> Tree,fitll Tree using GotObject from repository

func NewTree

func NewTree(oid common.Hash) *Tree

func (*Tree) Append

func (t *Tree) Append(entry *TreeEntry)

func (*Tree) Content

func (t *Tree) Content() string

func (*Tree) EntryCount

func (t *Tree) EntryCount() int

func (*Tree) Find

func (t *Tree) Find(name string) *TreeEntry

func (*Tree) ForEach

func (t *Tree) ForEach(fn WalkTreeEntryFunc)

func (*Tree) Hash

func (t *Tree) Hash() common.Hash

func (*Tree) Id

func (t *Tree) Id() common.Hash

func (*Tree) Kind

func (t *Tree) Kind() ObjectKind

func (*Tree) RegularizeEntries

func (t *Tree) RegularizeEntries()

Update, remove extra empty subtrees and update tree entries which are async with subtree Caution: empty tree entries will be remove and

func (*Tree) Sort

func (t *Tree) Sort()

func (*Tree) Subtree

func (t *Tree) Subtree(name string) *TreeEntry

func (*Tree) ToGitObject

func (t *Tree) ToGitObject() *GitObject

func (*Tree) ZeroId

func (t *Tree) ZeroId()

type TreeEntry

type TreeEntry struct {
	Oid      common.Hash
	Kind     ObjectKind
	Name     string
	Filemode common.FileMode

	// Pointer to Subtree(*Tree) or Blob(*Blob) identified by oid and implement common Object interface
	Pointer Object
}

100644 blob ec1871edcbfdc0d17ef498030e7ca676f291393d LICENSE // Blob and Tree Object both implemente TreeEntry interface

func NewTreeEntry

func NewTreeEntry(id common.Hash, name string, filemode common.FileMode) *TreeEntry

type TreeEntryCollection

type TreeEntryCollection []*TreeEntry

type TreeFs

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

mapping from fullpath to Tree object

func EmptyTreeFs

func EmptyTreeFs() *TreeFs

func NewTreeFs

func NewTreeFs(root *Tree) *TreeFs

func (*TreeFs) DFWalk

func (fs *TreeFs) DFWalk(fn WalkWithPathFunc, preordering bool)

Depth-first Walk, travel all trees

func (*TreeFs) DFWalkWithPrefix

func (fs *TreeFs) DFWalkWithPrefix(prefix string, fn WalkWithPathFunc, preordering bool)

func (*TreeFs) Debug

func (c *TreeFs) Debug()

func (*TreeFs) Find

func (fs *TreeFs) Find(path string) *Tree

func (*TreeFs) InitWithRoot

func (fs *TreeFs) InitWithRoot(r *Tree)

func (*TreeFs) MakeTreeAll

func (fs *TreeFs) MakeTreeAll(path string) *Tree

MakeTreeAll creates a tree named path, along with any necessary parents, and returns nil, or else returns an error. Return the tree if it has alright existed, do nothing else.

func (*TreeFs) Merge

func (fs *TreeFs) Merge(anothor *TreeFs)

func (*TreeFs) Root

func (fs *TreeFs) Root() *Tree

func (*TreeFs) WalkByPath

func (fs *TreeFs) WalkByPath(path string, fn WalkFunc, preordering bool)

WalkbyPath, travel all trees that along with the path

type TreePair

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

type WalkFunc

type WalkFunc func(*Tree) error

type WalkTreeEntryFunc

type WalkTreeEntryFunc func(*TreeEntry) error

type WalkWithPathFunc

type WalkWithPathFunc func(string, *Tree) error

Jump to

Keyboard shortcuts

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