store

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

func CloseAll added in v0.0.5

func CloseAll(all []io.Closer, reverse bool) error

CloseAll 关闭列表中的所有项目, 如果 reverse==true, 就从后往前执行

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 Binding

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

Binding ...

func GetBinding

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

GetBinding ...

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

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

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

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

type Entity

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

Entity ...

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 interface {
	NodeLocation

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

HEAD ...

type ImportPackParams added in v0.0.8

type ImportPackParams struct {
	ID        git.PackID
	PackFile  afs.Path
	IdxFile   afs.Path
	MoveFiles bool
}

ImportPackParams ...

type ImportPackResult added in v0.0.8

type ImportPackResult struct {
	Params *ImportPackParams
	ID     git.PackID
	Pack   Pack
}

ImportPackResult ...

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() ServiceManager

	Connectors() pktline.ConnectorManager

	// 把这个 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 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 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 git.Object

Object ... 建议直接使用 git.Object

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

type PackBuilder interface {
	io.Closer

	WriteObject(o *Object, data io.Reader) (*Object, error)
}

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

type PackObject interface {
	GetID() git.ObjectID
	Container() Pack
}

PackObject 表示包内对象

type PackReadCloser added in v0.0.8

type PackReadCloser interface {
	io.Closer
	GetIndex() PackIndex
	GetPack() PackFile
}

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 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) ([]afs.Path, 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

	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 Service added in v0.0.5

type Service interface {
}

Service is the Runner for Command

type ServiceManager added in v0.0.5

type ServiceManager interface {
	Find(name string) (Service, error)
}

ServiceManager 用来管理已注册的服务

type ServiceRegistration added in v0.0.5

type ServiceRegistration struct {
	Name    string
	Service Service
}

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

type SparseObject interface {
	Path() afs.Path

	GetID() git.ObjectID

	Exists() bool
}

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

type Submodules interface {
	Get(name string) Submodule
	List() []Submodule
}

Submodules ...

type Task added in v0.0.5

type Task interface {
	GetMeta() *Meta
	Run() error
}

Task 接口表示git-command-object 的外观

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 表示工作区目录

type Worktree added in v0.0.14

type Worktree interface {
	Name() string
	Workspace() Workspace
	Exists() bool
}

Worktree ...

type Worktrees added in v0.0.14

type Worktrees interface {
	Get(name string) Worktree
	List() []Worktree
}

Worktrees ...

Jump to

Keyboard shortcuts

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