store

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONFIG  = "config"
	INDEX   = "index"
	OBJECTS = "objects"
	REFS    = "refs"
)

定义各个git组件的名称

View Source
const MaxPathDepth = 256

MaxPathDepth 最大路径深度

Variables

This section is empty.

Functions

func Bind

func Bind(cc context.Context) context.Context

Bind ...

Types

type Algorithm

type Algorithm interface {
	GetInfo() *AlgorithmRegistration
}

Algorithm 表示抽象的算法

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 Binding

type Binding interface {
	SetLib(lib Lib) error
	GetLib() (Lib, error)
}

Binding ...

func GetBinding

func GetBinding(cc context.Context) (Binding, error)

GetBinding ...

type Compression

type Compression interface {
	Algorithm
}

Compression 压缩算法

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

type ContextConfigurer interface {
	Configure(c *Context) error
}

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

type CoreConfigurer interface {
	Configure(c *Core) error
}

CoreConfigurer 是用来配置 repository.Core 的组件 [inject:".git-core-configurer"]

type Digest

type Digest interface {
	Algorithm
}

Digest 摘要算法

type Entity

type Entity interface {
	OpenReader() (io.ReadCloser, error)
}

Entity ...

type HEAD interface {
	NodeLocation

	GetValue(s Session) (dxo.ReferenceName, error)
}

HEAD ...

type Index

type Index interface {
	NodeLocation
}

Index ...

type InfoFolder

type InfoFolder interface {
	Path() afs.Path
}

InfoFolder 代表 {.git}/objects/info

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 仓库布局对象创建器

func (*LayoutBuilder) Create

func (inst *LayoutBuilder) Create() RepositoryLayout

Create 创建仓库布局对象

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 ...

func GetLib

func GetLib(cc context.Context) (Lib, error)

GetLib 从给定的 Context 取与之绑定的 Lib 对象

type LibAgent added in v0.0.3

type LibAgent interface {
	GetLib() (Lib, error)
}

LibAgent ... [inject:"#git-lib-agent"]

type Node

type Node struct {
	Name string
	Path afs.FS
	Type NodeType
}

Node 表示 git 中的一个 dir 或者 file

type NodeLocation

type NodeLocation interface {
	Path() afs.Path
	NodeType() NodeType
}

NodeLocation 提供节点的路径

type NodeType

type NodeType string

NodeType 表示Node的类型

const (
	NodeConfig    NodeType = ".git/config"
	NodeObjects   NodeType = ".git/objects"
	NodeDotGit    NodeType = ".git"
	NodeWorkspace NodeType = ".git/.."
	NodeIndex     NodeType = ".git/index"
	NodeHEAD      NodeType = ".git/HEAD"
)

定义各种 Node 的类型

type Object

type Object struct {
	ID     dxo.ObjectID
	Type   string
	Length int64
	Entity Entity
}

Object 表示一个git对象

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 Repository

type Repository interface {
	RepositoryProfile
}

Repository ...

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

type SparseObject interface {
	Path() afs.Path

	GetID() dxo.ObjectID

	Exists() bool
}

SparseObject 表示稀疏对象

type Workspace

type Workspace interface {
	Path() afs.Path
}

Workspace 表示工作区目录

Jump to

Keyboard shortcuts

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