Documentation
¶
Overview ¶
Package gitops 封裝所有 git 操作,根據 workspace config 決定 monorepo 或 multi-repo 模式。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFileIfExists ¶
CopyFileIfExists 複製檔案,來源不存在時靜默忽略(回 nil);讀寫失敗回傳 error。供外部 package 使用。
func CopyFileIfNewer ¶
CopyFileIfNewer 僅在來源比目標新(或目標不存在)時複製,用於差量化 worktree sync, 避免每輪 final sync 與每 2 秒 live-sync 對未變更檔案重複全量複製。 回傳是否實際複製、以及錯誤;來源不存在視為靜默成功(false, nil)。 比對採 mtime-only:dst 不存在則複製;兩者皆存在時 srcInfo.ModTime().After(dstInfo.ModTime()) 才複製。
Types ¶
type MergeResult ¶
type MergeResult struct {
Skipped bool
Conflict bool
Error string
Files []string
ConflictRepo string
}
MergeResult 描述 Merge 操作的結果。
type Ops ¶
type Ops interface {
SetupWorktree(featureID string, featureRepos []string) (wtRoot string, err error)
Commit(wtRoot, featureID, msg string) error
Merge(featureID, featureName string) MergeResult
Cleanup(featureID string) error
DetectChangedRepos(featureID string) []string
DetectChangedFiles(featureID string) []protocol.ChangedFile
CaptureBaseline(featureID string, featureRepos []string) error
IsMultiRepo() bool
}
Ops 封裝所有 git 操作,根據 workspace config 決定 monorepo 或 multi-repo 模式。
type WorktreeInfo ¶ added in v0.1.13
type WorktreeInfo struct {
// Root 是該目錄所屬 worktree 的 top-level 根目錄(git rev-parse --show-toplevel)。
Root string
// IsLinked 為 true 表示這是 git worktree add 產生的 linked worktree;
// false 表示主工作區(main working tree)。
IsLinked bool
}
WorktreeInfo 描述某個目錄所屬的 git worktree 狀態。
func DetectWorktree ¶ added in v0.1.13
func DetectWorktree(dir string) (WorktreeInfo, bool)
DetectWorktree 偵測 dir 所屬的 git worktree,回傳其 top-level 根目錄與是否為 linked worktree。
scope 檢查在 worktree 隔離模式下,git 操作的根目錄會被解析到 main workspace, 導致誤把 main 的未提交變更算進 feature 的 changed repos。此 helper 讓呼叫端能 把 git 操作限定在 worktree 自身的根目錄。
判定方式:以 git rev-parse --git-dir 與 --git-common-dir 是否相異判定是否為 linked worktree(linked worktree 的 git-dir 指向 <common>/.git/worktrees/<name>,與 common dir 不同)。dir 不在 git repo 內時回傳 ok=false。