remote

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangedFile

type ChangedFile struct {
	Path   string     // relative path within the store (e.g. "ssh/config")
	Action FileAction // how the file was changed
}

ChangedFile represents a single file affected by a sync operation.

type Config

type Config struct {
	StoreDir string // local store directory path
	Repo     string // git repository URL
	Branch   string // git branch name
}

Config holds the configuration needed to initialize a remote.

type FileAction

type FileAction string

FileAction describes how a file was changed during sync.

const (
	FileAdded    FileAction = "added"
	FileModified FileAction = "modified"
	FileDeleted  FileAction = "deleted"
)

type GitRemote

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

GitRemote implements Remote using a git repository via go-git.

func NewGitRemote

func NewGitRemote() *GitRemote

NewGitRemote creates a new uninitialized GitRemote. Call Init before use.

func (*GitRemote) Init

func (g *GitRemote) Init(cfg Config) error

func (*GitRemote) Pull

func (g *GitRemote) Pull(force bool) (*PullResult, error)

func (*GitRemote) Push

func (g *GitRemote) Push(message string) (*PushResult, error)

func (*GitRemote) Status

func (g *GitRemote) Status() (*SyncStatus, error)

func (*GitRemote) Type

func (g *GitRemote) Type() string

type PullResult

type PullResult struct {
	Files    []ChangedFile
	UpToDate bool // true when no remote changes were found
}

PullResult contains the outcome of a pull operation.

type PushResult

type PushResult struct {
	Files []ChangedFile
}

PushResult contains the outcome of a push operation.

type Remote

type Remote interface {
	// Init initializes the remote with the given configuration.
	// For git, this clones or opens the repository at Config.StoreDir.
	Init(config Config) error

	// Push uploads local store changes to the remote.
	Push(message string) (*PushResult, error)

	// Pull downloads remote changes to the local store.
	// If force is true, local changes are overwritten.
	Pull(force bool) (*PullResult, error)

	// Status returns the current sync state between local and remote.
	Status() (*SyncStatus, error)

	// Type returns the remote type identifier (e.g. "git").
	Type() string
}

Remote abstracts storage backends for syncing the hako store. Implementations handle the transport layer (git, cloud APIs, etc.) while the sync engine handles file operations and conflict resolution.

type SyncStatus

type SyncStatus struct {
	LocalChanges  int
	RemoteChanges int
}

SyncStatus reports pending changes on both sides.

Jump to

Keyboard shortcuts

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