sync

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 23, 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, verbosity int, logf func(string, ...interface{}), tracef func(string, ...interface{})) *Engine

NewEngine creates a new sync engine. verbosity controls logging: 0=quiet, 1=verbose (cmd/exit), 2=trace (also raw output).

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.

func (*Engine) StatusRepo added in v0.2.0

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

StatusRepo reads the current state of a repository without modifying it. It returns ActionDirty if the working tree is dirty, ActionBranchDrift if the repo is on a non-default branch (and clean), or ActionAlreadyCurrent if the repo is clean and on the default branch.

type ExecGitRunner

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

ExecGitRunner runs real git commands. When tracef is set, the raw output of each command is forwarded to it.

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) StatusShort added in v0.2.0

func (g *ExecGitRunner) StatusShort(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)
	StatusShort(repoDir string) (string, error) // returns colorized short status output
}

GitRunner executes git commands. Abstracted for testability.

func NewLoggingGitRunner added in v0.3.3

func NewLoggingGitRunner(next GitRunner, logf func(string, ...interface{})) GitRunner

NewLoggingGitRunner wraps a GitRunner and emits command diagnostics via logf. If logf is nil the original runner is returned unwrapped.

type LoggingGitRunner added in v0.3.3

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

LoggingGitRunner decorates a GitRunner with verbose command diagnostics. Before each operation it emits "git cmd: <command>" and afterward "git exit: 0" on success or "git exit: 1 error=<message>" on failure, along with any structured result values.

func (*LoggingGitRunner) Checkout added in v0.3.3

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

func (*LoggingGitRunner) Clone added in v0.3.3

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

func (*LoggingGitRunner) CurrentBranch added in v0.3.3

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

func (*LoggingGitRunner) DiffStats added in v0.3.3

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

func (*LoggingGitRunner) Fetch added in v0.3.3

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

func (*LoggingGitRunner) IsDirty added in v0.3.3

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

func (*LoggingGitRunner) PullFF added in v0.3.3

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

func (*LoggingGitRunner) RemoteURL added in v0.3.3

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

func (*LoggingGitRunner) StatusShort added in v0.3.3

func (g *LoggingGitRunner) StatusShort(repoDir string) (string, error)

func (*LoggingGitRunner) SubmoduleUpdate added in v0.3.3

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

Jump to

Keyboard shortcuts

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