Documentation
¶
Index ¶
- Constants
- Variables
- type CheckoutFetchedCall
- type CommitCall
- type EnsureRepoCall
- type FakeGitPersistence
- func (f *FakeGitPersistence) CheckoutFetched(ctx context.Context, repoRoot, branch string) error
- func (f *FakeGitPersistence) Commit(ctx context.Context, repoRoot, message string, paths []string) error
- func (f *FakeGitPersistence) EnsureRepo(ctx context.Context, repoRoot, branch string) error
- func (f *FakeGitPersistence) Fetch(ctx context.Context, repoRoot, remote, branch string) error
- func (f *FakeGitPersistence) GetRemoteURL(ctx context.Context, repoRoot, remoteName string) (string, error)
- func (f *FakeGitPersistence) Push(ctx context.Context, repoRoot, remote, branch string, force bool) error
- func (f *FakeGitPersistence) SetRemote(ctx context.Context, repoRoot, remoteName, url string) error
- type FetchCall
- type FileRemoteConfigStore
- type GetRemoteCall
- type GitPersistence
- type PushCall
- type RealGitPersistence
- func (g *RealGitPersistence) CheckoutFetched(ctx context.Context, repoRoot, branch string) error
- func (g *RealGitPersistence) Commit(ctx context.Context, repoRoot, message string, paths []string) error
- func (g *RealGitPersistence) EnsureRepo(ctx context.Context, repoRoot, branch string) error
- func (g *RealGitPersistence) Fetch(ctx context.Context, repoRoot, remote, branch string) error
- func (g *RealGitPersistence) GetRemoteURL(ctx context.Context, repoRoot, remoteName string) (string, error)
- func (g *RealGitPersistence) Push(ctx context.Context, repoRoot, remote, branch string, force bool) error
- func (g *RealGitPersistence) SetRemote(ctx context.Context, repoRoot, remoteName, url string) error
- type RemoteConfig
- type RemoteConfigStore
- type SetRemoteCall
Constants ¶
const ( // DefaultRemoteName is the default Git remote to use for persistence DefaultRemoteName = "origin" // DefaultBranch is the default orphan branch name for persistence DefaultBranch = "monodev/persist" // RemoteConfigFileName is the name of the remote config file RemoteConfigFileName = "remote.json" )
Variables ¶
var ( // ErrRemoteNotConfigured is returned when a remote operation is attempted // but no remote configuration exists. ErrRemoteNotConfigured = errors.New("remote not configured, run 'monodev remote use <name>'") // ErrRemoteNotFound is returned when the specified remote doesn't exist // in the main repository's git config. ErrRemoteNotFound = errors.New("remote not found in repository") // ErrBranchNotFound is returned when the persistence branch doesn't exist // on the remote. ErrBranchNotFound = errors.New("persistence branch not found on remote") // ErrStoreNotInRemote is returned when attempting to pull a store that // doesn't exist in the remote persistence repository. ErrStoreNotInRemote = errors.New("store not found in remote") // ErrFingerprintMismatch is returned when a workspace ref's repo fingerprint // doesn't match the current repository. ErrFingerprintMismatch = errors.New("workspace repository fingerprint mismatch") )
var ( // ErrPersistenceWorkTreeDirty is returned when pulling would move the // persistence branch while tracked changes are present in its work tree. ErrPersistenceWorkTreeDirty = errors.New("persistence work tree has uncommitted changes") // ErrPersistenceBranchDiverged is returned when the fetched commit cannot // fast-forward the local persistence branch. ErrPersistenceBranchDiverged = errors.New("local persistence branch has diverged from fetched branch") )
Functions ¶
This section is empty.
Types ¶
type CheckoutFetchedCall ¶ added in v0.3.0
type CommitCall ¶
type EnsureRepoCall ¶
type FakeGitPersistence ¶
type FakeGitPersistence struct {
EnsureRepoCalls []EnsureRepoCall
CommitCalls []CommitCall
PushCalls []PushCall
FetchCalls []FetchCall
CheckoutFetchedCalls []CheckoutFetchedCall
GetRemoteCalls []GetRemoteCall
SetRemoteCalls []SetRemoteCall
// Configurable responses
EnsureRepoErr error
CommitErr error
PushErr error
FetchErr error
CheckoutFetchedErr error
RemoteURL string
GetRemoteErr error
SetRemoteErr error
EnsureRepoHook func(context.Context, EnsureRepoCall) error
CommitHook func(context.Context, CommitCall) error
PushHook func(context.Context, PushCall) error
FetchHook func(context.Context, FetchCall) error
CheckoutFetchedHook func(context.Context, CheckoutFetchedCall) error
GetRemoteHook func(context.Context, GetRemoteCall) error
SetRemoteHook func(context.Context, SetRemoteCall) error
}
FakeGitPersistence is a test double that tracks operations without executing them.
func NewFakeGitPersistence ¶
func NewFakeGitPersistence() *FakeGitPersistence
NewFakeGitPersistence creates a new FakeGitPersistence.
func (*FakeGitPersistence) CheckoutFetched ¶ added in v0.3.0
func (f *FakeGitPersistence) CheckoutFetched(ctx context.Context, repoRoot, branch string) error
func (*FakeGitPersistence) EnsureRepo ¶
func (f *FakeGitPersistence) EnsureRepo(ctx context.Context, repoRoot, branch string) error
func (*FakeGitPersistence) Fetch ¶
func (f *FakeGitPersistence) Fetch(ctx context.Context, repoRoot, remote, branch string) error
func (*FakeGitPersistence) GetRemoteURL ¶
type FileRemoteConfigStore ¶
type FileRemoteConfigStore struct {
// contains filtered or unexported fields
}
FileRemoteConfigStore is a file-based implementation of RemoteConfigStore.
func NewFileRemoteConfigStore ¶
func NewFileRemoteConfigStore(fs fsops.FS) *FileRemoteConfigStore
NewFileRemoteConfigStore creates a new FileRemoteConfigStore.
func (*FileRemoteConfigStore) Exists ¶
func (s *FileRemoteConfigStore) Exists(repoRoot string) (bool, error)
Exists checks if a remote configuration file exists.
func (*FileRemoteConfigStore) Load ¶
func (s *FileRemoteConfigStore) Load(repoRoot string) (*RemoteConfig, error)
Load reads the remote configuration from disk.
func (*FileRemoteConfigStore) Save ¶
func (s *FileRemoteConfigStore) Save(repoRoot string, config *RemoteConfig) error
Save writes the remote configuration to disk using atomic writes.
type GetRemoteCall ¶
type GitPersistence ¶
type GitPersistence interface {
// EnsureRepo initializes the persistence Git repository if it doesn't exist.
// Creates a separate git repository with GIT_DIR=.monodev/.git and GIT_WORK_TREE=.monodev.
// Also creates and checks out the orphan branch if needed.
EnsureRepo(ctx context.Context, repoRoot, branch string) error
// Commit stages the specified paths and creates a commit with the given message.
Commit(ctx context.Context, repoRoot, message string, paths []string) error
// Push pushes the specified branch to the remote.
Push(ctx context.Context, repoRoot, remote, branch string, force bool) error
// Fetch fetches the specified branch from the remote.
Fetch(ctx context.Context, repoRoot, remote, branch string) error
// CheckoutFetched fast-forwards the specified branch to the exact commit
// recorded in FETCH_HEAD and checks it out in the .monodev work tree.
CheckoutFetched(ctx context.Context, repoRoot, branch string) error
// GetRemoteURL retrieves the URL of the specified remote from the main repository.
GetRemoteURL(ctx context.Context, repoRoot, remoteName string) (string, error)
// SetRemote configures a remote in the persistence repository.
SetRemote(ctx context.Context, repoRoot, remoteName, url string) error
}
GitPersistence provides operations for the separate Git persistence repository. This repository lives at .monodev/.git with work tree at .monodev.
type RealGitPersistence ¶
type RealGitPersistence struct{}
RealGitPersistence is the production implementation using exec.CommandContext.
func NewRealGitPersistence ¶
func NewRealGitPersistence() *RealGitPersistence
NewRealGitPersistence creates a new RealGitPersistence.
func (*RealGitPersistence) CheckoutFetched ¶ added in v0.3.0
func (g *RealGitPersistence) CheckoutFetched(ctx context.Context, repoRoot, branch string) error
CheckoutFetched fast-forwards branch to the exact commit in FETCH_HEAD. It refuses dirty or divergent persistence state rather than resetting it.
func (*RealGitPersistence) Commit ¶
func (g *RealGitPersistence) Commit(ctx context.Context, repoRoot, message string, paths []string) error
Commit stages paths and creates a commit.
func (*RealGitPersistence) EnsureRepo ¶
func (g *RealGitPersistence) EnsureRepo(ctx context.Context, repoRoot, branch string) error
EnsureRepo initializes the persistence repository.
func (*RealGitPersistence) Fetch ¶
func (g *RealGitPersistence) Fetch(ctx context.Context, repoRoot, remote, branch string) error
Fetch fetches the branch from the remote.
func (*RealGitPersistence) GetRemoteURL ¶
func (g *RealGitPersistence) GetRemoteURL(ctx context.Context, repoRoot, remoteName string) (string, error)
GetRemoteURL retrieves the URL of a remote from the main repository.
type RemoteConfig ¶
type RemoteConfig struct {
// SchemaVersion identifies the on-disk remote configuration format.
SchemaVersion int `json:"schemaVersion"`
// Remote is the name of the Git remote to use (e.g., "origin")
Remote string `json:"remote"`
// Branch is the orphan branch name for persistence (e.g., "monodev/persist")
Branch string `json:"branch"`
// UpdatedAt is the last time this configuration was modified
UpdatedAt time.Time `json:"updated_at"`
}
RemoteConfig represents the configuration for remote persistence operations. It's stored repo-locally at .monodev/remote.json.
func DefaultRemoteConfig ¶
func DefaultRemoteConfig() *RemoteConfig
DefaultRemoteConfig returns a RemoteConfig with default values.
type RemoteConfigStore ¶
type RemoteConfigStore interface {
// Load reads the remote configuration from the specified repo root.
// Returns ErrRemoteNotConfigured if the config file doesn't exist.
Load(repoRoot string) (*RemoteConfig, error)
// Save writes the remote configuration to the specified repo root.
Save(repoRoot string, config *RemoteConfig) error
// Exists checks if a remote configuration exists for the specified repo root.
Exists(repoRoot string) (bool, error)
}
RemoteConfigStore is an interface for loading and saving remote configuration.