Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow dolt init on dolt repo with just config.json #8838

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

jycor
Copy link
Contributor

@jycor jycor commented Feb 7, 2025

This PR changes dolt init to allow the dolt repo to still be created when there are no global users, but there are local users in .dolt/config.json.

In order to get to that state you must do

mkdir .dolt
dolt config --add user.email <email>
dolt config --add user.name <name>

related: #8835

@coffeegoddd
Copy link
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
3c2e6f1 ok 5937457
version total_tests
3c2e6f1 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Contributor

@jycor DOLT

comparing_percentages
100.000000 to 100.000000
version result total
62484c4 ok 5937457
version total_tests
62484c4 5937457
correctness_percentage
100.0

Copy link
Contributor

@fulghum fulghum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double check the logic in that condition I commented on, and then this looks good to go. Could be worth adding a test where a .dolt dir does have a TimDirName directory in it to make sure that case is working as expected.

Comment on lines +67 to +70
run dolt config --add user.name foo
[ "$status" -eq 0 ]
run dolt config --add user.email [email protected]
[ "$status" -eq 0 ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(minor) if you just want to ensure that the commend exits with a success status (without checking any output), you can omit run and you'll get that automatically. Not a big deal, but saves a couple lines.

Suggested change
run dolt config --add user.name foo
[ "$status" -eq 0 ]
run dolt config --add user.email [email protected]
[ "$status" -eq 0 ]
dolt config --add user.name foo
dolt config --add user.email [email protected]

@@ -499,7 +499,7 @@ func (dEnv *DoltEnv) createDirectories(dir string) (string, error) {
}

if len(entries) == 1 {
if !entries[0].IsDir() || entries[0].Name() != TmpDirName {
if (!entries[0].IsDir() && entries[0].Name() != TmpDirName) && (!entries[0].IsDir() && entries[0].Name() != configFile) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic doesn't seem correct to me 🤔 Looking at the original logic... seems like we were originally allowing only a directory named TmpDirName, but this new logic wouldn't allow that anymore.

I think you actually want something like this:

Suggested change
if (!entries[0].IsDir() && entries[0].Name() != TmpDirName) && (!entries[0].IsDir() && entries[0].Name() != configFile) {
entry := entries[0]
if (entry.IsDir && entry.Name() != TmpDirName) || (!entry.IsDir() && entry.Name() != configFile) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants