sync

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseGitStatus

func ParseGitStatus(output string) []model.DirtyFile

ParseGitStatus parses git status --porcelain output into DirtyFile entries. This is a pure function for testability.

Types

type Decision

type Decision struct {
	ShouldFetch    bool
	ShouldCheckout bool
	ShouldPull     bool
	SkipReason     string
}

Decision represents what actions should be taken for a repository.

func DecideActions

func DecideActions(isDirty bool, currentBranch string, defaultBranch string) Decision

DecideActions determines what git operations to perform based on repo state. This is a pure function for testability.

type Engine

type Engine struct {
	Git     GitRunner
	BaseDir string
	Verbose bool
}

Engine orchestrates per-repo sync operations.

func NewEngine

func NewEngine(baseDir string, verbose bool) *Engine

NewEngine creates a new sync engine.

func (*Engine) CloneRepo

func (e *Engine) CloneRepo(repo model.RepoInfo) model.RepoResult

CloneRepo clones a missing repository.

func (*Engine) ProcessRepo

func (e *Engine) ProcessRepo(repo model.RepoInfo) model.RepoResult

ProcessRepo audits and syncs an existing local repository.

type ExecGitRunner

type ExecGitRunner struct{}

ExecGitRunner runs real git commands.

func (*ExecGitRunner) Checkout

func (g *ExecGitRunner) Checkout(repoDir, branch string) error

func (*ExecGitRunner) Clone

func (g *ExecGitRunner) Clone(url, dest string) error

func (*ExecGitRunner) CurrentBranch

func (g *ExecGitRunner) CurrentBranch(repoDir string) (string, error)

func (*ExecGitRunner) DiffStats

func (g *ExecGitRunner) DiffStats(repoDir string) (int, int, error)

func (*ExecGitRunner) Fetch

func (g *ExecGitRunner) Fetch(repoDir string) error

func (*ExecGitRunner) IsDirty

func (g *ExecGitRunner) IsDirty(repoDir string) (bool, []model.DirtyFile, error)

func (*ExecGitRunner) PullFF

func (g *ExecGitRunner) PullFF(repoDir string) (bool, error)

func (*ExecGitRunner) RemoteURL

func (g *ExecGitRunner) RemoteURL(repoDir string) (string, error)

func (*ExecGitRunner) SubmoduleUpdate

func (g *ExecGitRunner) SubmoduleUpdate(repoDir string) error

type GitRunner

type GitRunner interface {
	Clone(url, dest string) error
	Fetch(repoDir string) error
	SubmoduleUpdate(repoDir string) error
	CurrentBranch(repoDir string) (string, error)
	IsDirty(repoDir string) (bool, []model.DirtyFile, error)
	DiffStats(repoDir string) (int, int, error) // additions, deletions
	Checkout(repoDir, branch string) error
	PullFF(repoDir string) (bool, error) // returns true if changes were pulled
	RemoteURL(repoDir string) (string, error)
}

GitRunner executes git commands. Abstracted for testability.

Jump to

Keyboard shortcuts

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