git

package
v0.0.16 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashBytes added in v0.0.5

func HashBytes(x HashID) []byte

HashBytes 稳妥的取 bytes

func HashCompare added in v0.0.8

func HashCompare(h1, h2 HashID) int

HashCompare 比较两个ID的大小

func HashEqual added in v0.0.5

func HashEqual(h1, h2 HashID) bool

HashEqual 判断两个ID是否相等

func HashString added in v0.0.5

func HashString(x HashID) string

HashString 稳妥的取 string

func SetDefaultIdentityFactory added in v0.0.5

func SetDefaultIdentityFactory(f IdentityFactory)

SetDefaultIdentityFactory ...

Types

type Algorithm added in v0.0.8

type Algorithm interface {
	GetInfo() *AlgorithmRegistration
}

Algorithm 表示抽象的算法

type AlgorithmRegistration added in v0.0.8

type AlgorithmRegistration struct {
	Name     string
	Type     AlgorithmType
	Provider Algorithm
}

AlgorithmRegistration ...

type AlgorithmRegistry added in v0.0.8

type AlgorithmRegistry interface {
	ListRegistrations() []*AlgorithmRegistration
}

AlgorithmRegistry ... [inject:".git-algorithm-registry"]

type AlgorithmType added in v0.0.8

type AlgorithmType int

AlgorithmType 表示算法的类型

const (
	AlgorithmCompression AlgorithmType = 1
	AlgorithmDigest      AlgorithmType = 2
	AlgorithmPathMapping AlgorithmType = 3
)

定义几种算法的类型

type Commit added in v0.0.2

type Commit struct {
	HyperMessage

	Parents   []ObjectID
	Tree      ObjectID
	Author    *Operator
	Committer *Operator
}

Commit ...

type CommonID added in v0.0.8

type CommonID interface {
	HashID
	ObjectID
	PackID
}

CommonID ... 表示一个多用途的ID

type Compression added in v0.0.8

type Compression interface {
	Algorithm

	NewReader(r io.Reader) (io.ReadCloser, error)
	NewWriter(w io.Writer) (io.WriteCloser, error)
}

Compression 压缩算法

type Digest added in v0.0.8

type Digest interface {
	Algorithm

	Size() HashSize

	New() hash.Hash
}

Digest 摘要算法

type HEAD struct {
	Name ReferenceName // the Primary-Key
	ID   ObjectID      // 不常用
}

HEAD 是表示一个 .git/HEAD 的实体

type HashID added in v0.0.5

type HashID interface {
	GetFactory() IdentityFactory

	Size() HashSize

	Bytes() []byte

	String() string

	GetByte(index int) byte
}

HashID 表示git的一个 hash 值

func HashZero added in v0.0.5

func HashZero() HashID

HashZero 取 0

type HashSize added in v0.0.8

type HashSize int

HashSize 表示 Hash 的长度, 单位是 byte

func HashSizeInBytes added in v0.0.8

func HashSizeInBytes(n int) HashSize

HashSizeInBytes ...

func (HashSize) IsValid added in v0.0.8

func (size HashSize) IsValid() bool

IsValid ...

func (HashSize) SizeInBits added in v0.0.8

func (size HashSize) SizeInBits() int

SizeInBits ...

func (HashSize) SizeInBytes added in v0.0.8

func (size HashSize) SizeInBytes() int

SizeInBytes ...

func (HashSize) SizeInRune added in v0.0.8

func (size HashSize) SizeInRune() int

SizeInRune ...

type HyperHeader added in v0.0.5

type HyperHeader struct {
	Name   string
	Values []string
}

HyperHeader ...

func (*HyperHeader) AddValue added in v0.0.5

func (inst *HyperHeader) AddValue(v string)

AddValue ....

func (*HyperHeader) AddValues added in v0.0.5

func (inst *HyperHeader) AddValues(src []string)

AddValues ....

type HyperMessage added in v0.0.5

type HyperMessage struct {
	ID      ObjectID
	Headers map[string]*HyperHeader
	Content string
}

HyperMessage ...

type IdentityFactory added in v0.0.5

type IdentityFactory interface {
	Size() HashSize

	Zero() CommonID

	Create(b []byte) CommonID

	Parse(s string) CommonID

	TryCreate(b []byte) (CommonID, error)

	TryParse(s string) (CommonID, error)
}

IdentityFactory 表示git的一个 hash 值

func DefaultIdentityFactory added in v0.0.5

func DefaultIdentityFactory() IdentityFactory

DefaultIdentityFactory ...

type Object added in v0.0.8

type Object struct {
	ID     ObjectID
	Type   ObjectType
	Length int64
}

Object 表示一个git对象

type ObjectID added in v0.0.5

type ObjectID interface {
	HashID
	OID() ObjectID
}

ObjectID 表示git的 object-ID

func CreateObjectID added in v0.0.5

func CreateObjectID(b []byte) (ObjectID, error)

CreateObjectID ...

func ParseObjectID added in v0.0.5

func ParseObjectID(s string) (ObjectID, error)

ParseObjectID ...

type ObjectType added in v0.0.8

type ObjectType string

ObjectType 表示git对象类型

const (
	ObjectTypeTag    ObjectType = "tag"
	ObjectTypeCommit ObjectType = "commit"
	ObjectTypeTree   ObjectType = "tree"
	ObjectTypeBLOB   ObjectType = "blob"

	ObjectTypeOfsDelta ObjectType = "OBJ_OFS_DELTA"
	ObjectTypeRefDelta ObjectType = "OBJ_REF_DELTA"
)

定义各种对象类型

func (ObjectType) String added in v0.0.8

func (v ObjectType) String() string

type Operator added in v0.0.5

type Operator struct {
	Name  string
	Email string
	Time  time.Time
	Zone  string
}

Operator ...

type PackID added in v0.0.5

type PackID interface {
	HashID
	PID() PackID
}

PackID 表示git的包ID

func CreatePackID added in v0.0.5

func CreatePackID(b []byte) (PackID, error)

CreatePackID ...

func ParsePackID added in v0.0.5

func ParsePackID(s string) (PackID, error)

ParsePackID ...

type PackIdxFanOut added in v0.0.8

type PackIdxFanOut struct {
	Data [256]uint32
}

PackIdxFanOut ...

func (*PackIdxFanOut) Total added in v0.0.8

func (inst *PackIdxFanOut) Total() int64

Total 返回总条数

type PackIndex added in v0.0.8

type PackIndex struct {
	Head  PackIndexHead
	Items []*PackIndexItem
}

PackIndex ...

type PackIndexHead added in v0.0.8

type PackIndexHead struct {
	Version int // 1 or 2
	Total   int64
	FanOut  PackIdxFanOut
}

PackIndexHead ...

type PackIndexItem added in v0.0.8

type PackIndexItem struct {
	OID    ObjectID
	Offset int64 // the offset in pack file
	CRC32  uint32

	// ext
	PID        PackID
	Exists     bool
	Index      int64 // the index in idx table
	Length     int64
	Type       ObjectType
	PackedType PackedObjectType // in-pack entity
}

PackIndexItem ...

type PackedObjectHeader added in v0.0.8

type PackedObjectHeader struct {
	Type PackedObjectType
	Size int64
}

PackedObjectHeader ...

type PackedObjectHeaderEx added in v0.0.8

type PackedObjectHeaderEx struct {
	PackedObjectHeader

	PID PackID
	OID ObjectID

	Offset int64 // head(type+length)
	// Offset1 int64 //  end(type+length)
	// Offset2 int64 // head(raw_data)
	// Offset3 int64 //  end(raw_data)
	CRC32 int64 // = idx.item[n].crc32

	DeltaRef    ObjectID
	DeltaOffset int64
}

PackedObjectHeaderEx ...

func (*PackedObjectHeaderEx) GetDeltaParentOffset added in v0.0.8

func (inst *PackedObjectHeaderEx) GetDeltaParentOffset() int64

GetDeltaParentOffset 计算 delta-parent 的绝对位置

type PackedObjectType added in v0.0.8

type PackedObjectType int

PackedObjectType 表示pack内对象的类型

const (
	PackedCommit PackedObjectType = 1 // OBJ_COMMIT    = (1)
	PackedTree   PackedObjectType = 2 // OBJ_TREE      = (2)
	PackedBLOB   PackedObjectType = 3 // OBJ_BLOB      = (3)
	PackedTag    PackedObjectType = 4 // OBJ_TAG       = (4)

	PackedDeltaOFS PackedObjectType = 6 // OBJ_OFS_DELTA = (6)
	PackedDeltaRef PackedObjectType = 7 // OBJ_REF_DELTA = (7)
)

定义 pack 对象类型

func (PackedObjectType) ToObjectType added in v0.0.8

func (v PackedObjectType) ToObjectType() ObjectType

ToObjectType ... 转换为 git.ObjectType 类型

type PathMapping added in v0.0.8

type PathMapping interface {
	Algorithm

	WithPattern(pattern string) PathMapping

	Map(base afs.Path, id ObjectID) afs.Path
}

PathMapping 路径映射算法

type Properties added in v0.0.5

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

Properties 表示属性文档格式,例如 .git/config 文件

func (*Properties) Clear added in v0.0.5

func (inst *Properties) Clear()

Clear ...

func (*Properties) Export added in v0.0.5

func (inst *Properties) Export(dst map[string]string) map[string]string

Export ...

func (*Properties) Get added in v0.0.5

func (inst *Properties) Get(name string) string

Get ...

func (*Properties) Import added in v0.0.5

func (inst *Properties) Import(src map[string]string)

Import ...

func (*Properties) Set added in v0.0.5

func (inst *Properties) Set(name, value string)

Set ...

func (*Properties) Trim added in v0.0.5

func (inst *Properties) Trim()

Trim ...

type Ref added in v0.0.5

type Ref struct {
	ID   ObjectID      // the Primary-Key
	Name ReferenceName // 不常用
}

Ref 是表示一个 .git/refs/[type]/[name] 的实体

type ReferenceName added in v0.0.5

type ReferenceName string

ReferenceName is the name for .git/refs/*

func (ReferenceName) IsWildcard added in v0.0.8

func (v ReferenceName) IsWildcard() bool

IsWildcard ...

func (ReferenceName) Normalize added in v0.0.5

func (v ReferenceName) Normalize() ReferenceName

Normalize ...

func (ReferenceName) NormalizeWithType added in v0.0.5

func (v ReferenceName) NormalizeWithType(aType string) ReferenceName

NormalizeWithType ...

func (ReferenceName) String added in v0.0.5

func (v ReferenceName) String() string

type Tag added in v0.0.5

type Tag struct {
	HyperMessage

	Target    ObjectID
	Author    *Operator
	Committor *Operator
}

Tag ...

type Tree added in v0.0.5

type Tree struct {
	ID    ObjectID // 此 tree 对象的 ID
	Items []*TreeItem
}

Tree ...

type TreeItem added in v0.0.5

type TreeItem struct {
	Name string
	ID   ObjectID // 该条目的 ID
	Mode TreeItemMode
}

TreeItem ...

func (*TreeItem) Executable added in v0.0.8

func (inst *TreeItem) Executable() bool

Executable ...

func (*TreeItem) IsFile added in v0.0.8

func (inst *TreeItem) IsFile() bool

IsFile ...

func (*TreeItem) IsFolder added in v0.0.8

func (inst *TreeItem) IsFolder() bool

IsFolder ...

type TreeItemMode added in v0.0.8

type TreeItemMode string

TreeItemMode 表示树上文件(或子目录)的模式

const (
	TreeItemModeFolder TreeItemMode = "40000"
	TreeItemModeFile   TreeItemMode = "100644"
	TreeItemModeExe    TreeItemMode = "100755"
)

定义树上文件模式

Jump to

Keyboard shortcuts

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