Documentation
¶
Index ¶
- Constants
- func Bind(cc context.Context) context.Context
- type Algorithm
- type AlgorithmManager
- type AlgorithmRegistration
- type AlgorithmRegistry
- type AlgorithmType
- type Binding
- type Compression
- type Config
- type ConfigChain
- type ConfigChainFactory
- type ConfigChainParams
- type ConfigScope
- type Context
- type ContextConfiguration
- type ContextConfigurer
- type ContextFactory
- type Core
- type CoreConfigurer
- type Digest
- type Entity
- type HEAD
- type Index
- type InfoFolder
- type LayoutBuilder
- type Lib
- type LibAgent
- type Node
- type NodeLocation
- type NodeType
- type Object
- type Objects
- type Pack
- type PathMapping
- type Ref
- type Refs
- type Repository
- type RepositoryConfig
- type RepositoryFinder
- type RepositoryLayout
- type RepositoryLoader
- type RepositoryLocator
- type RepositoryProfile
- type Session
- type SessionFactory
- type SparseObject
- type Workspace
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) (Algorithm, error) FindCompression(name string) (Compression, error) FindDigest(name string) (Digest, error) FindPathMapping(name string) (PathMapping, error) }
AlgorithmManager 是用来管理各种算法的对象
type AlgorithmRegistration ¶ added in v0.0.3
type AlgorithmRegistration struct { Name string Type AlgorithmType Provider Algorithm }
AlgorithmRegistration ...
type AlgorithmRegistry ¶ added in v0.0.3
type AlgorithmRegistry interface {
ListRegistrations() []*AlgorithmRegistration
}
AlgorithmRegistry ... [inject:".git-algorithm-registry"]
type AlgorithmType ¶
type AlgorithmType int
AlgorithmType 表示算法的类型
const ( AlgorithmCompression AlgorithmType = 1 AlgorithmDigest AlgorithmType = 2 AlgorithmPathMapping AlgorithmType = 3 )
定义几种算法的类型
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 []AlgorithmRegistry Services []instructions.ServiceRegistry CoreConfigurers []CoreConfigurer FS afs.FS Locator RepositoryLocator Finder RepositoryFinder ServiceManager instructions.ServiceManager RepositoryLoader RepositoryLoader ConfigChainFactory ConfigChainFactory AlgorithmManager AlgorithmManager }
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 SessionFactory SessionFactory Digest Digest // default="SHA-1" Compression Compression // default="DEFLATE" PathMapping PathMapping // default="xx/xxxx" }
Core 表示仓库对象的核心
type CoreConfigurer ¶
CoreConfigurer 是用来配置 repository.Core 的组件 [inject:".git-core-configurer"]
type HEAD ¶
type HEAD interface { NodeLocation GetValue(s Session) (dxo.ReferenceName, error) }
HEAD ...
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() instructions.ServiceManager // 把这个 Lib 绑定到指定的 Context Bind(cc context.Context) context.Context }
Lib ...
type NodeLocation ¶
NodeLocation 提供节点的路径
type Objects ¶
type Objects interface { Path() afs.Path GetObject(oid dxo.ObjectID) SparseObject GetPack(pid dxo.PackID) Pack Info() InfoFolder }
Objects 接口代表 {.git}/objects
type Pack ¶
type Pack interface { GetID() dxo.PackID GetIndexFile() afs.Path GetEntityFile() afs.Path Exists() bool }
Pack 代表 {.git}/objects/pack
type PathMapping ¶
type PathMapping interface { Algorithm WithPattern(pattern string) PathMapping Map(base afs.Path, id dxo.ObjectID) afs.Path }
PathMapping 路径映射算法
type Ref ¶
type Ref interface { Path() afs.Path Name() dxo.ReferenceName Exists() bool GetValue(s Session) (dxo.ObjectID, error) }
Ref is the key-value for .git/refs/*
type Refs ¶
type Refs interface { Path() afs.Path GetRef(name dxo.ReferenceName) Ref }
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 ¶
type RepositoryFinder interface {
Find(pwd afs.Path) ([]RepositoryLayout, error)
}
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 }
RepositoryLayout 表示关于一个仓库的几个关键路径
type RepositoryLoader ¶
type RepositoryLoader interface {
Load(l RepositoryLayout) (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 OpenSession() (Session, error) }
RepositoryProfile 表示一个存在的git仓库的视图
type Session ¶
type Session interface { io.Closer // 取仓库接口 GetRepository() RepositoryProfile // 根据名称,取指定的组件 GetComponent(name string) (any, error) // 取工作目录 GetWD() afs.Path // 取仓库布局 GetLayout() RepositoryLayout // objects LoadCommit(id dxo.ObjectID) (*dxo.Commit, error) LoadTag(id dxo.ObjectID) (*dxo.Tag, error) LoadTree(id dxo.ObjectID) (*dxo.Tree, error) // HEAD LoadHEAD(head HEAD) (dxo.ReferenceName, error) }
Session ...
type SessionFactory ¶
type SessionFactory interface {
OpenSession(profile RepositoryProfile) (Session, error)
}
SessionFactory ...
type SparseObject ¶
SparseObject 表示稀疏对象