dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Refactor Dolt repository requirement checks to be command and context-aware

Open elianddb opened this issue 1 month ago • 0 comments

The current implementation uses a static list to determine which commands require a valid Dolt repository. This approach is incorrect because repository requirements depend on both the subcommand being executed and whether the command is running locally or connecting to a remote host.

For example, dolt backup sync requires a local repository, while dolt backup restore does not. Similarly, dolt init should only run locally and never over a remote connection, while dolt sql can run in both contexts.

The static list approach forces overly broad decisions that apply to all subcommands of a command, when the requirement should be determined dynamically.

// Current
commandsNotRequiringRepo := map[string]bool{
    "init": true,
    "sql": true,
    "sql-server": true,
    "backup": true,  // Too broad - depends on subcommand
}
// Proposal
type RepoNotRequiredCommand interface {
    // RequiresRepo returns whether the command requires a valid repository
    // based on the subcommand and connection context.
    RequiresRepo(subcommand string, isRemoteConnection bool) bool
}

elianddb avatar Dec 08 '25 21:12 elianddb