dolthub / dolthub/dolt

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

Open
#10,181 0 comments 0 reactions 0 assignees View on GitHub
enhancement version control
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 8h
Merged PRs (30d)
120

Description

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.

```go
// Current
commandsNotRequiringRepo := map[string]bool{
"init": true,
"sql": true,
"sql-server": true,
"backup": true, // Too broad - depends on subcommand
}
```

```go
// 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
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the static commandsNotRequiringRepo map and the command-dispatch logic that uses it. Trace how backup subcommands, init, and sql determine local versus remote execution, then replace the broad checks with command- and context-aware behavior and verify the examples in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.