Documentation
¶
Index ¶
- func CanFastForward(path, branch string) bool
- func Clone(url, path, token string) error
- func CommitsBehind(path, branch string) (int, error)
- func CurrentBranch(path string) (string, error)
- func FastForward(path string) error
- func Fetch(path, token string) error
- func IsClean(path string) bool
- func IsRepo(path string) bool
- func RemoteURL(path string) (string, error)
- type SyncResult
- type SyncStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanFastForward ¶
CanFastForward returns true if HEAD can be fast-forwarded to origin/branch.
func Clone ¶
Clone clones a git repository. If token is non-empty, it is passed as an HTTP authorization header for private repo access.
func CommitsBehind ¶
CommitsBehind returns the number of commits HEAD is behind origin/branch.
func CurrentBranch ¶
CurrentBranch returns the name of the currently checked-out branch.
func FastForward ¶
FastForward performs a fast-forward merge from the upstream tracking branch.
func Fetch ¶
Fetch runs git fetch origin in the given repository. If token is non-empty, it is passed as an HTTP authorization header for private repo access.
Types ¶
type SyncResult ¶
type SyncResult struct {
Status SyncStatus
Commits int // Number of commits pulled (only for StatusPulled)
Error error // Underlying error (only for StatusError)
}
SyncResult holds the outcome of syncing a repository.
func SyncRepo ¶
func SyncRepo(path, token string) SyncResult
SyncRepo fetches from origin and conditionally fast-forwards. It never modifies a dirty worktree and never does non-fast-forward merges. If token is non-empty, it is passed to git fetch for private repo access.
type SyncStatus ¶
type SyncStatus int
SyncStatus represents the outcome of a sync operation.
const ( StatusPulled SyncStatus = iota // Fast-forwarded successfully StatusUpToDate // Already at latest commit StatusFetched // Fetched only (dirty worktree or diverged) StatusError // Operation failed )