gitrepo

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: AGPL-3.0 Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitrepo 管理带版本的受管后端仓库。

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFetcher = errors.New("git fetcher is invalid")
)
View Source
var ErrInvalidVersion = errors.New("version is invalid")

ErrInvalidVersion 表示产品版本不能安全映射为发布分支。

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	Healthy bool
	Version string
	Branch  string
	Commit  string
	Source  string
	Reason  string
	// contains filtered or unexported fields
}

CheckResult 是 workspace check 的稳定业务结果,不携带路径或 remote URL。

type Error

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

Error 描述工作区 Git 服务失败,供 CLI 映射协议四元组。

func (*Error) Code

func (e *Error) Code() protocol.Code

Code 返回稳定协议错误码。

func (*Error) Committed

func (e *Error) Committed() bool

Committed 报告错误是否发生在仓库激活提交点之后。

func (*Error) Details

func (e *Error) Details() map[string]any

Details 返回只包含稳定分类事实的协议详情。

func (*Error) Error

func (e *Error) Error() string

func (*Error) Message

func (e *Error) Message() string

Message 返回不包含路径、URL 或底层错误文本的用户文案。

func (*Error) Stage

func (e *Error) Stage() protocol.Stage

Stage 返回失败发生的稳定阶段。

func (*Error) Unwrap

func (e *Error) Unwrap() error

type FetchRequest

type FetchRequest struct {
	Plan          mirror.Plan
	Target        Target
	OperationID   string
	StageReporter StageReporter
}

FetchRequest 固定一次 Git 获取操作的目标、镜像计划和目录所有者。

type FetchResult

type FetchResult struct {
	RepositoryPath    string
	Revision          Revision
	DirectoryIdentity *filesystem.DirectoryIdentity
	CommitMessage     string
}

FetchResult 保存已验证临时仓库的安全路径和最终来源事实。

type Fetcher

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

Fetcher 获取并验证一个固定目标分支,不负责激活仓库目录。

func NewFetcher

func NewFetcher(
	layout *config.Layout,
	rotator *mirror.Rotator,
	remover *filesystem.Operator,
	verifier *Verifier,
	emitter ProgressEmitter,
) (*Fetcher, error)

NewFetcher 创建使用 go-git 传输和真实静态校验器的仓库获取器。

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(ctx context.Context, request FetchRequest) (FetchResult, error)

Fetch 按镜像计划获取同一 Target,并只返回通过静态校验的临时仓库。

type LoggerFactory

type LoggerFactory func(ctx context.Context, command, operationID string) (OperationLogger, error)

LoggerFactory 延迟创建本次同步的 Runtime logger,确保 check 保持只读。

type MutationCoordinator

type MutationCoordinator interface {
	AcquireMutation(context.Context) (MutationLease, error)
	Close() error
}

MutationCoordinator 提供一次受管 mutation 操作的锁生命周期。

func NewMutationCoordinator

func NewMutationCoordinator(ctx context.Context, layout *config.Layout) (MutationCoordinator, error)

NewMutationCoordinator 创建可由上层编排持有的生产 mutation 锁协调器。

type MutationLease

type MutationLease interface {
	Close() error
}

MutationLease 是跨 workspace 与环境编排共享的 mutation 锁租约。

type OperationLogger

type OperationLogger interface {
	LogPath() string
	Close() error
}

OperationLogger 是同步操作所需的日志生命周期能力。

type PlanBuilder added in v0.1.7

type PlanBuilder func(context.Context, mirror.Policy) (mirror.Plan, error)

PlanBuilder 按策略给出 Git 源的尝试顺序;增补 2 C16 起由测速排序实现注入,默认按目录顺序。

type ProgressEmitter

type ProgressEmitter interface {
	EmitProgress(event protocol.ProgressEvent) error
}

ProgressEmitter 是 Fetcher 消费的单方法协议进度出口。

type Recovery

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

Recovery 按 update transaction 和三个精确目录身份恢复中断现场。

func NewRecovery

func NewRecovery(
	layout *config.Layout,
	operator *filesystem.Operator,
	store *state.Store,
) (*Recovery, error)

NewRecovery 创建使用真实 filesystem、state Store 和 go-git reader 的恢复服务。

func (*Recovery) Recover

func (r *Recovery) Recover(
	ctx context.Context,
	request RecoveryRequest,
) (RecoveryResult, error)

Recover 在任何目录副作用前完成全部必要身份分类。

type RecoveryRequest

type RecoveryRequest struct {
	DiscardStaged bool
	LogPath       string
	StageReporter StageReporter
}

RecoveryRequest 提供补写 repository_changed 所需的当前 Runtime 日志路径。

type RecoveryResult

type RecoveryResult struct {
	Recovered          bool
	MutationApplied    bool
	EnvironmentWritten bool
	TransactionRemoved bool
	Version            string
	Branch             string
	Commit             string
	SourceKey          string
}

RecoveryResult 保存恢复动作和已证明 active revision 的事实。

type RemoteCheckResult added in v0.1.2

type RemoteCheckResult struct {
	Current         CheckResult
	RemoteCommit    string
	UpdateAvailable bool
}

RemoteCheckResult 是 workspace check --remote 的只读结果。

type Revision

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

Revision 保存经静态校验的仓库版本、分支、Commit 和来源。

func NewRevision

func NewRevision(version, branch, commit, sourceKey string) (Revision, error)

NewRevision 构造一个经版本、分支、Commit 和来源校验的稳定 revision。 应用层测试替身和跨包编排只能通过该构造器取得 Revision,不能伪造内部字段。

func (Revision) Branch

func (r Revision) Branch() string

Branch 返回目标发布分支。

func (Revision) Commit

func (r Revision) Commit() string

Commit 返回 40 位小写 Git Commit。

func (Revision) SourceKey

func (r Revision) SourceKey() string

SourceKey 返回最终成功网络源的稳定 key。

func (Revision) Version

func (r Revision) Version() string

Version 返回完整产品版本。

type Service

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

Service 是 workspace check/sync 的应用服务;check 不创建任何运行时能力。

func NewService

func NewService(layout *config.Layout, options ...ServiceOption) (*Service, error)

NewService 创建使用生产 go-git、filesystem、state 和 Windows Mutex 的服务。

func (*Service) Check

func (s *Service) Check(ctx context.Context) (CheckResult, error)

Check 只读取 app-root/repo 及其 Git 对象,不创建目录、状态、锁、日志或网络请求。

func (*Service) CheckRemote added in v0.1.2

func (s *Service) CheckRemote(ctx context.Context, policy mirror.Policy) (RemoteCheckResult, error)

CheckRemote 只读取当前仓库和远端分支引用,不创建受管状态或下载工作区。

func (*Service) Stage added in v0.1.2

func (s *Service) Stage(ctx context.Context, request StageRequest) (result StageResult, returnErr error)

Stage 只写独立暂存仓库与 update 事务,允许当前后端保持运行。

func (*Service) Sync

func (s *Service) Sync(ctx context.Context, request SyncRequest) (result SyncResult, returnErr error)

Sync 按冻结顺序执行锁协调、恢复、Git 获取、整体替换和环境失效持久化。

type ServiceOption added in v0.1.7

type ServiceOption func(*serviceOptions) error

ServiceOption 配置 NewService 的可注入依赖。

func WithPlanBuilder added in v0.1.7

func WithPlanBuilder(build PlanBuilder) ServiceOption

WithPlanBuilder 注入 Git 源尝试顺序的构造函数(例如 mirror.Ranker 的实测排序)。

type StageReporter

type StageReporter func(protocol.Stage)

StageReporter 让 CLI 的 stdin 控制 warning 使用当前真实 stage。

type StageRequest added in v0.1.2

type StageRequest = SyncRequest

StageRequest 使用同一套操作身份与日志依赖;暂存自己获取锁,不接受外部 mutation 租约。

type StageResult added in v0.1.2

type StageResult struct {
	Revision      Revision
	Staged        bool
	CommitMessage string
}

StageResult 只有已完整校验且不同于当前仓库时才报告 Staged。

type SwapRequest

type SwapRequest struct {
	Transaction    state.TransactionState
	Revision       Revision
	ActiveIdentity *filesystem.DirectoryIdentity
	UpdateIdentity *filesystem.DirectoryIdentity
	StageReporter  StageReporter
	// CommitEnvironment 在新仓库激活且 cleanup transaction 持久化后调用。
	// 回调必须先持久化 repository_changed,Swapper 才会删除 previous。
	CommitEnvironment func(context.Context, Revision) error
}

SwapRequest 把已验证 Revision 绑定到当前 update transaction。

type SwapResult

type SwapResult struct {
	Revision            Revision
	MutationApplied     bool
	RepositoryActivated bool
	CleanupCompleted    bool
}

SwapResult 保存目录副作用、激活提交点和旧目录收口事实。

type Swapper

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

Swapper 通过封闭 filesystem 能力整体替换受管仓库。

func NewSwapper

func NewSwapper(
	layout *config.Layout,
	operator *filesystem.Operator,
	transactions *state.Store,
) (*Swapper, error)

NewSwapper 创建使用真实受控文件系统和状态 Store 的仓库替换器。

func (*Swapper) Swap

func (s *Swapper) Swap(ctx context.Context, request SwapRequest) (SwapResult, error)

Swap 在 update transaction 保护下执行两次 rename 和旧目录收口。

type SyncRequest

type SyncRequest struct {
	UseCurrent       bool
	Target           Target
	Policy           mirror.Policy
	OperationID      string
	PID              uint32
	MutationLease    MutationLease
	Emitter          WorkspaceEmitter
	LoggerFactory    LoggerFactory
	Auditor          filesystem.Auditor
	Clock            func() time.Time
	StageReporter    StageReporter
	ControlCommandID func() string
}

SyncRequest 描述一次 workspace sync 的外部依赖和稳定身份。

type SyncResult

type SyncResult struct {
	Revision         Revision
	Changed          bool
	Status           protocol.StateStatus
	ControlCommandID string
}

SyncResult 是 workspace sync 的稳定业务结果。

type Target

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

Target 保存经校验的产品版本及其唯一发布分支。

func ParseTarget

func ParseTarget(version string) (Target, error)

ParseTarget 校验产品版本并按固定模板创建目标。

func (Target) Branch

func (t Target) Branch() string

Branch 返回产品版本唯一派生的发布分支。

func (Target) Version

func (t Target) Version() string

Version 返回未经规范化的完整产品版本。

type VerificationRequest

type VerificationRequest struct {
	RepositoryPath string
	Target         Target
	Source         mirror.Source
	AllowedSources []mirror.Source
}

VerificationRequest 固定静态校验所需的路径、目标和本次网络源集合。

type Verifier

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

Verifier 校验克隆仓库的来源、分支、对象边界和版本文档。

func NewVerifier

func NewVerifier() *Verifier

NewVerifier 创建使用 go-git 本地对象读取器的静态验证器。

func (*Verifier) Verify

func (v *Verifier) Verify(
	ctx context.Context,
	request VerificationRequest,
) (Revision, error)

Verify 返回与可变仓库对象隔离的 Revision。

type WorkspaceEmitter

type WorkspaceEmitter interface {
	EmitProgress(protocol.ProgressEvent) error
	EmitState(protocol.StateEvent) error
}

WorkspaceEmitter 是同步服务使用的最小协议事件出口。

Jump to

Keyboard shortcuts

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