sync

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sync performs weft's git synchronization: commit local changes, rebase-pull, then push. It is weft's second deliberate disk-mutating surface (alongside internal/edit) and shells out to the system `git`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Committed bool   // a commit was created (working tree had changes)
	Pulled    bool   // pull --rebase advanced the working tree
	Pushed    bool   // push succeeded
	Stage     string // failing stage; "" on success
	Output    string // combined output of the failing stage; "" on success
	Err       error  // non-nil on failure
}

Result reports what a sync did and, on failure, where it stopped.

func Run

func Run(repoDir string, now time.Time) Result

Run performs commit -> pull --rebase -> push against repoDir. now is the commit-timestamp source, injected so callers (and tests) stay deterministic.

type WorktreeStatus

type WorktreeStatus struct {
	Dirty bool // working tree has uncommitted changes
	Ahead int  // commits on HEAD not yet on the upstream branch (0 if no upstream)
}

WorktreeStatus is a read-only snapshot of where the graph repo stands relative to its last commit and its upstream. It is the read sibling of Run.

func Status

func Status(repoDir string) (WorktreeStatus, error)

Status probes repoDir's git state without mutating anything. It returns an error only when repoDir is not inside a git work tree; callers treat that as "no indicator" rather than a failure. A missing upstream is not an error — Ahead is simply left 0, since there's nothing local to measure against.

func (WorktreeStatus) Unsynced

func (s WorktreeStatus) Unsynced() bool

Unsynced reports whether there is local work not yet pushed: either uncommitted changes or committed-but-unpushed commits.

Jump to

Keyboard shortcuts

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