Skip to content

Commit dc303d0

Browse files
committed
cmds(repo rm-root): bring --remove-existing-root in-line with it's documentation
This command is already annoying enough. If a user decides to automate this, that's their issue (and we should allow it). (also rename back to remove-existing-root from remove-local-root) License: MIT Signed-off-by: Steven Allen <[email protected]>
1 parent 03e79f4 commit dc303d0

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

core/commands/repo.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ This command can only run when the ipfs daemon is not running.
286286
},
287287
Options: []cmdkit.Option{
288288
cmdkit.BoolOption("confirm", "Really perform operation."),
289-
cmdkit.BoolOption("remove-local-root", "Remove even if the root exists locally."),
289+
cmdkit.BoolOption("remove-existing-root", "Remove even if it root exists locally."),
290290
},
291291
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
292292
confirm, _ := req.Options["confirm"].(bool)
293-
removeLocalRoot, _ := req.Options["remove-local-root"].(bool)
293+
removeExistingRoot, _ := req.Options["remove-existing-root"].(bool)
294294

295295
if !confirm {
296296
return fmt.Errorf("this is a potentially dangerous operation please pass --confirm to proceed")
@@ -328,10 +328,8 @@ This command can only run when the ipfs daemon is not running.
328328
cidStr = b58.Encode(val)
329329
}
330330

331-
if have && !removeLocalRoot {
332-
return fmt.Errorf("root %s exists locally. Are you sure you want to unlink this? Pass --remove-local-root to continue", cidStr)
333-
} else if !have && removeLocalRoot {
334-
return fmt.Errorf("root does not %s exists locally. Please remove --remove-local-root to continue", cidStr)
331+
if have && !removeExistingRoot {
332+
return fmt.Errorf("root %s exists locally. Are you sure you want to unlink this? Pass --remove-existing-root to continue", cidStr)
335333
}
336334

337335
err = repo.Datastore().Delete(core.FilesRootKey)

test/sharness/t0089-repo-rm-root.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ test_expect_success "ipfs repo rm-root fails without --confirm" '
1818
fgrep -q "please pass --confirm to proceed" err
1919
'
2020

21-
test_expect_success "ipfs repo rm-root fails to remove existing root without --remove-local-root" '
21+
test_expect_success "ipfs repo rm-root fails to remove existing root without --remove-existing-root" '
2222
test_must_fail ipfs repo rm-root --confirm 2> err &&
2323
cat err &&
2424
fgrep -q "Are you sure you want to unlink this?" err
2525
'
2626

2727
test_expect_success "ipfs repo rm-root" '
28-
ipfs repo rm-root --confirm --remove-local-root | tee rm-root.actual &&
28+
ipfs repo rm-root --confirm --remove-existing-root | tee rm-root.actual &&
2929
echo "Unlinked files API root. Root hash was $ROOT_HASH." > rm-root.expected &&
3030
test_cmp rm-root.expected rm-root.actual
3131
'

0 commit comments

Comments
 (0)