Documentation
¶
Index ¶
- Constants
- func Bind(cc context.Context) context.Context
- func CloseAll(all []io.Closer, reverse bool) error
- type AlgorithmManager
- type Binding
- type Config
- type ConfigChain
- type ConfigChainFactory
- type ConfigChainParams
- type ConfigScope
- type Context
- type ContextConfiguration
- type ContextConfigurer
- type ContextFactory
- type Core
- type CoreConfigurer
- type Entity
- type FileReaderPool
- type HEAD
- type ImportPackParams
- type ImportPackResult
- type Index
- type InfoFolder
- type LayoutBuilder
- type Lib
- type LibAgent
- type Meta
- type Node
- type NodeLocation
- type NodeType
- type Object
- type Objects
- type Pack
- type PackBuilder
- type PackFile
- type PackIndex
- type PackObject
- type PackReadCloser
- type Packs
- type Ref
- type Refs
- type Repository
- type RepositoryConfig
- type RepositoryFinder
- type RepositoryLayout
- type RepositoryLoader
- type RepositoryLocator
- type RepositoryProfile
- type Service
- type ServiceManager
- type ServiceRegistration
- type ServiceRegistry
- type Session
- type SessionFactory
- type SparseObject
- type SparseObjects
- type Submodule
- type Submodules
- type Task
- type TemporaryBuffer
- type Workspace
- type Worktree
- type Worktrees
Constants ¶
const ( CONFIG = "config" INDEX = "index" OBJECTS = "objects" REFS = "refs" )
定义各个git组件的名称
const MaxPathDepth = 256
MaxPathDepth 最大路径深度
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlgorithmManager ¶ added in v0.0.3
type AlgorithmManager interface {
Find(name string) (git.Algorithm, error)
FindCompression(name string) (git.Compression, error)
FindDigest(name string) (git.Digest, error)
FindPathMapping(name string) (git.PathMapping, error)
}
AlgorithmManager 是用来管理各种算法的对象
type Config ¶
type Config interface {
NodeLocation
RepositoryConfig
Save() error
Load() error
}
Config 统一的抽象配置接口
type ConfigChain ¶
type ConfigChain interface {
Config() Config
Mix() ConfigChain
Parent() ConfigChain
Scope() ConfigScope
FindByScope(scope ConfigScope) ConfigChain
Load() error
}
ConfigChain ... 表示配置对象构成的责任链
type ConfigChainFactory ¶
type ConfigChainFactory interface {
Create(p *ConfigChainParams) ConfigChain
Root() ConfigChain
}
ConfigChainFactory ...
type ConfigChainParams ¶
type ConfigChainParams struct {
File afs.Path
Parent ConfigChain
Scope ConfigScope
Required bool
IgnoreCase bool
}
ConfigChainParams 创建配置连的参数
type ConfigScope ¶
type ConfigScope int
ConfigScope 表示配置属性的作用域
const ( ConfigScopeDefault ConfigScope = 0 ConfigScopeSystem ConfigScope = 1 ConfigScopeUser ConfigScope = 2 ConfigScopeRepository ConfigScope = 3 ConfigScopeMix ConfigScope = 4 ConfigScopeCommand ConfigScope = 11 ConfigScopeWorktree ConfigScope = 12 ConfigScopeFinal ConfigScope = 99 )
定义配置属性的作用域
type Context ¶
type Context struct {
Lib Lib
CLI cli.CLI
Algorithms []git.AlgorithmRegistry
Services []ServiceRegistry
CoreConfigurers []CoreConfigurer
Connectors []pktline.Connector
FS afs.FS
Locator RepositoryLocator
Finder RepositoryFinder
ServiceManager ServiceManager
RepositoryLoader RepositoryLoader
ConfigChainFactory ConfigChainFactory
AlgorithmManager AlgorithmManager
ConnectorManager pktline.ConnectorManager // the main connector
}
Context 表示仓库对象的周边环境
type ContextConfiguration ¶
type ContextConfiguration struct {
Factory ContextFactory
ContextConfigurers []ContextConfigurer
CoreConfigurers []CoreConfigurer
UseCLI bool
CLIConfig *cli.Configuration
CLI cli.CLI
}
ContextConfiguration 是用来初始化模块的配置
type ContextConfigurer ¶
ContextConfigurer 是用来配置 repository.Context 的组件 [inject:".git-context-configurer"]
type ContextFactory ¶
type ContextFactory interface {
Create(cfg *ContextConfiguration) (*Context, error)
// get info about the factory
String() string
}
ContextFactory 是用来创建 repository.Context 的工厂
type Core ¶
type Core struct {
WD afs.Path // 工作目录
Context *Context
Config ConfigChain // 配置链:repo -> user -> system
Head HEAD
Index Index
Layout RepositoryLayout
Objects Objects
Refs Refs
Repository RepositoryProfile
Workspace Workspace // aka the default worktree
Worktrees Worktrees
Submodules Submodules
SessionFactory SessionFactory
Digest git.Digest // default="SHA-1"
Compression git.Compression // default="DEFLATE"
PathMapping git.PathMapping // default="xx/xxxx"
}
Core 表示仓库对象的核心
type CoreConfigurer ¶
CoreConfigurer 是用来配置 repository.Core 的组件 [inject:".git-core-configurer"]
type FileReaderPool ¶ added in v0.0.8
type FileReaderPool interface {
io.Closer
OpenReader(file afs.Path, op *afs.Options) (io.ReadSeekCloser, error)
}
FileReaderPool ...
type HEAD ¶
type HEAD interface {
NodeLocation
GetValue(s Session) (git.ReferenceName, error)
}
HEAD ...
type ImportPackParams ¶ added in v0.0.8
ImportPackParams ...
type ImportPackResult ¶ added in v0.0.8
type ImportPackResult struct {
Params *ImportPackParams
ID git.PackID
Pack Pack
}
ImportPackResult ...
type LayoutBuilder ¶
type LayoutBuilder struct {
WD afs.Path
DotGit afs.Path
Repository afs.Path // the repository core dir
Workspace afs.Path
SubmodulePoint afs.Path
WorktreePoint afs.Path
CorePoint afs.Path
Config afs.Path
HEAD afs.Path
Index afs.Path
Objects afs.Path
Refs afs.Path
}
LayoutBuilder 仓库布局对象创建器
type Lib ¶
type Lib interface {
FS() afs.FS
GetCLI(required bool) cli.CLI
RepositoryLoader() RepositoryLoader
RepositoryFinder() RepositoryFinder
RepositoryLocator() RepositoryLocator
InstructionServiceManager() ServiceManager
Connectors() pktline.ConnectorManager
// 把这个 Lib 绑定到指定的 Context
Bind(cc context.Context) context.Context
}
Lib ...
type Meta ¶ added in v0.0.5
type Meta struct {
Context context.Context
Name string // the command name
WD afs.Path // Working Directory
}
Meta 包含git-command-object 的基本字段
type NodeLocation ¶
NodeLocation 提供节点的路径
type Objects ¶
type Objects interface {
Path() afs.Path
GetSparseObject(oid git.ObjectID) SparseObject
GetPack(pid git.PackID) Pack
ListPacks() []git.PackID
Info() InfoFolder
}
Objects 接口代表 {.git}/objects
type Pack ¶
type Pack interface {
GetID() git.PackID
GetDotIdx() afs.Path
GetDotPack() afs.Path
GetObject(oid git.ObjectID) PackObject
Exists() bool
}
Pack 代表 {.git}/objects/pack
type PackBuilder ¶ added in v0.0.5
PackBuilder 读写包对象
type PackFile ¶ added in v0.0.8
type PackFile interface {
ReadPackObject(item *git.PackIndexItem) (io.ReadCloser, *git.Object, error)
}
PackFile 表示包内对象索引
type PackIndex ¶ added in v0.0.8
type PackIndex interface {
Count() int64
Get(index int64) (*git.PackIndexItem, error)
List(index, limit int64) ([]*git.PackIndexItem, error)
Find(id git.ObjectID) (*git.PackIndexItem, error)
}
PackIndex 表示包内对象索引
type PackObject ¶ added in v0.0.5
PackObject 表示包内对象
type PackReadCloser ¶ added in v0.0.8
PackReadCloser 表示包内对象索引
type Packs ¶ added in v0.0.8
type Packs interface {
FindPackObject(oid git.ObjectID) (PackObject, error)
FindPackObjectInPack(pid git.PackID, oid git.ObjectID) (PackObject, error)
ReadPackObject(o PackObject) (*git.Object, io.ReadCloser, error)
CheckPack(pid git.PackID, flags pack.CheckFlag) error
ListPacks() ([]git.PackID, error)
NewPackBuilder() PackBuilder
ImportPack(p *ImportPackParams) (*ImportPackResult, error)
}
Packs 读写包对象
type Ref ¶
type Ref interface {
Path() afs.Path
Name() git.ReferenceName
Exists() bool
GetValue(s Session) (git.ObjectID, error)
}
Ref is the key-value for .git/refs/*
type Refs ¶
type Refs interface {
Path() afs.Path
GetRef(name git.ReferenceName) Ref
List() []git.ReferenceName
}
Refs is the key-value for .git/refs/*
type RepositoryConfig ¶
type RepositoryConfig interface {
Import(src map[string]string)
Export() map[string]string
GetProperty(name string) string
SetProperty(name, value string)
Clear()
}
RepositoryConfig 表示基本的配置文件
type RepositoryFinder ¶
RepositoryFinder 表示一个git仓库查找器,用来查找指定路径下的所有仓库
type RepositoryLayout ¶
type RepositoryLayout interface {
// 取工作目录
WD() afs.Path
Workspace() afs.Path
DotGit() afs.Path
Repository() afs.Path
Config() afs.Path
Index() afs.Path
HEAD() afs.Path
Objects() afs.Path
Refs() afs.Path
IsBare() bool
IsSubmodule() bool
IsWorktree() bool
}
RepositoryLayout 表示关于一个仓库的几个关键路径
type RepositoryLoader ¶
type RepositoryLoader interface {
Load(l RepositoryLayout) (Repository, error)
LoadWithPath(path afs.Path) (Repository, error)
}
RepositoryLoader ...
type RepositoryLocator ¶
type RepositoryLocator interface {
Locate(pwd afs.Path) (RepositoryLayout, error)
}
RepositoryLocator 表示一个git仓库定位器,用来确定仓库的准确位置
type RepositoryProfile ¶
type RepositoryProfile interface {
Layout() RepositoryLayout
Config() ConfigChain
HEAD() HEAD
Index() Index
Refs() Refs
Objects() Objects
Worktrees() Worktrees
Submodules() Submodules
Digest() git.Digest // default="SHA-1"
Compression() git.Compression // default="DEFLATE"
PathMapping() git.PathMapping // default="xx/xxxx"
OpenSession() (Session, error)
}
RepositoryProfile 表示一个存在的git仓库的视图
type ServiceManager ¶ added in v0.0.5
ServiceManager 用来管理已注册的服务
type ServiceRegistration ¶ added in v0.0.5
ServiceRegistration ...
type ServiceRegistry ¶ added in v0.0.5
type ServiceRegistry interface {
ListRegistrations() []*ServiceRegistration
}
ServiceRegistry ... [inject:".git-instruction-registry"]
type Session ¶
type Session interface {
io.Closer
// 取仓库接口
GetRepository() Repository
// 根据名称,取指定的组件
GetComponent(name string) (any, error)
// 取工作目录
GetWD() afs.Path
// 取仓库布局
GetLayout() RepositoryLayout
// 新建临时文件
NewTemporaryFile(dir afs.Path) afs.Path
NewTemporaryBuffer(dir afs.Path) TemporaryBuffer
NewReaderPool(size int) afs.ReaderPool
GetReaderPool() afs.ReaderPool
GetObjectContext() *objects.Context
// objects
ReadObject(id git.ObjectID) (*git.Object, io.ReadCloser, error)
WriteObject(o *git.Object, data io.Reader) (*git.Object, error)
GetSparseObjects() SparseObjects
GetPacks() Packs
LoadText(id git.ObjectID) (string, *git.Object, error)
LoadBinary(id git.ObjectID) ([]byte, *git.Object, error)
// commit, tag, tree
LoadCommit(id git.ObjectID) (*git.Commit, error)
LoadTag(id git.ObjectID) (*git.Tag, error)
LoadTree(id git.ObjectID) (*git.Tree, error)
// refs
LoadRef(r Ref) (*git.Ref, error)
SaveRef(r *git.Ref) error
// HEAD
LoadHEAD(head HEAD) (*git.HEAD, error)
SaveHEAD(h *git.HEAD) error
}
Session ...
type SessionFactory ¶
type SessionFactory interface {
OpenSession(repo Repository) (Session, error)
}
SessionFactory ...
type SparseObject ¶
SparseObject 表示稀疏对象
type SparseObjects ¶ added in v0.0.8
type SparseObjects interface {
ReadSparseObject(o SparseObject) (*git.Object, io.ReadCloser, error)
ReadSparseObjectRaw(o SparseObject) (io.ReadCloser, error)
WriteSparseObject(o *git.Object, data io.Reader) (*git.Object, error)
WriteSparseObjectRaw(o *git.Object, data io.Reader) (*git.Object, error)
}
SparseObjects 读写稀疏对象
type Submodule ¶ added in v0.0.14
type Submodule interface {
Name() string
URL() string
Path() string
IsActive() bool
Workspace() Workspace
Exists() bool
}
Submodule ...
type Submodules ¶ added in v0.0.14
Submodules ...
type TemporaryBuffer ¶ added in v0.0.8
type TemporaryBuffer interface {
io.Closer
io.Writer
GetTemporaryFile() afs.Path
GetFlushSize() int
SetFlushSize(size int)
SaveToFile(dst afs.Path) error
}
TemporaryBuffer ...
type Workspace ¶
type Workspace interface {
// alias of WorkingDirectory
Path() afs.Path
// return the working directory
WorkingDirectory() afs.Path
// return the '.git' file or directory
DotGit() afs.Path
}
Workspace 表示工作区目录