Addressing PR Feedback

Renamed a variable to be more clear, and updated documentation for the --use-db flag.
This commit is contained in:
Neil Macneale IV
2023-05-18 09:21:13 -07:00
parent a5d23104c5
commit e6945a013f
2 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -633,7 +633,7 @@ func buildGlobalArgs() *argparser.ArgParser {
ap.SupportsString(commands.CfgDirFlag, "", "directory", "Defines a directory that contains configuration files for dolt. Defaults to `$data-dir/.doltcfg`. Will only be created if there is a change to configuration settings.")
ap.SupportsString(commands.PrivsFilePathFlag, "", "privilege file", "Path to a file to load and store users and grants. Defaults to `$doltcfg-dir/privileges.db`. Will only be created if there is a change to privileges.")
ap.SupportsString(commands.BranchCtrlPathFlag, "", "branch control file", "Path to a file to load and store branch control permissions. Defaults to `$doltcfg-dir/branch_control.db`. Will only be created if there is a change to branch control permissions.")
ap.SupportsString(commands.UseDbFlag, "", "database", "The name of the database to use when executing SQL queries. Defaults to the first database alphabetically.")
ap.SupportsString(commands.UseDbFlag, "", "database", "The name of the database to use when executing SQL queries. Defaults the database of the root directory, if it exists, and the first alphabetically if not.")
return ap
}
+9 -9
View File
@@ -69,31 +69,31 @@ func MultiEnvForSingleEnv(ctx context.Context, env *DoltEnv) (*MultiRepoEnv, err
func MultiEnvForDirectory(
ctx context.Context,
config config.ReadWriteConfig,
fs filesys.Filesys, // fs which is the root of the multi-env. This is essentially the --data-dir flag or cwd.
dataDirFS filesys.Filesys,
version string,
ignoreLockFile bool,
dEnv *DoltEnv,
) (*MultiRepoEnv, error) {
// Load current fs and put into mr env
// Load current dataDirFS and put into mr env
var dbName string = "dolt"
var newDEnv *DoltEnv = dEnv
// InMemFS is used only for testing.
// All other FS Types should get a newly created Envronment which will serve as the primary env in the MultiRepoEnv
if _, ok := fs.(*filesys.InMemFS); !ok {
path, err := fs.Abs("")
// All other FS Types should get a newly created Environment which will serve as the primary env in the MultiRepoEnv
if _, ok := dataDirFS.(*filesys.InMemFS); !ok {
path, err := dataDirFS.Abs("")
if err != nil {
return nil, err
}
envName := getRepoRootDir(path, string(os.PathSeparator))
dbName = dirToDBName(envName)
newDEnv = Load(ctx, GetCurrentUserHomeDir, fs, doltdb.LocalDirDoltDB, version)
newDEnv = Load(ctx, GetCurrentUserHomeDir, dataDirFS, doltdb.LocalDirDoltDB, version)
}
mrEnv := &MultiRepoEnv{
envs: make([]NamedEnv, 0),
fs: fs,
fs: dataDirFS,
cfg: config,
dialProvider: NewGRPCDialProviderFromDoltEnv(newDEnv),
ignoreLockFile: ignoreLockFile,
@@ -105,14 +105,14 @@ func MultiEnvForDirectory(
}
// If there are other directories in the directory, try to load them as additional databases
fs.Iter(".", false, func(path string, size int64, isDir bool) (stop bool) {
dataDirFS.Iter(".", false, func(path string, size int64, isDir bool) (stop bool) {
if !isDir {
return false
}
dir := filepath.Base(path)
newFs, err := fs.WithWorkingDir(dir)
newFs, err := dataDirFS.WithWorkingDir(dir)
if err != nil {
return false
}