Commit f31e6b61 authored by Kevin Atkinson's avatar Kevin Atkinson

Change --force-cid-base to --upgrade-cidv0-in-output.

License: MIT
Signed-off-by: default avatarKevin Atkinson <k@kevina.org>
parent 727aea1f
......@@ -10,7 +10,7 @@ import (
)
var OptionCidBase = cmdkit.StringOption("cid-base", "Multibase encoding used for version 1 CIDs in output.")
var OptionForceCidBase = cmdkit.BoolOption("force-cid-base", "Force multibase prefix by upgrading CIDv0 to CIDv1.")
var OptionUpgradeCidV0InOutput = cmdkit.BoolOption("upgrade-cidv0-in-output", "Upgrade version 0 to version 1 CIDs in output.")
// GetCidEncoder processes the `cid-base` and `output-cidv1` options and
// returns a encoder to use based on those parameters.
......@@ -27,7 +27,7 @@ func GetLowLevelCidEncoder(req *cmds.Request) (cidenc.Encoder, error) {
func getCidBase(req *cmds.Request, autoUpgrade bool) (cidenc.Encoder, error) {
base, _ := req.Options[OptionCidBase.Name()].(string)
upgrade, upgradeDefined := req.Options[OptionForceCidBase.Name()].(bool)
upgrade, upgradeDefined := req.Options[OptionUpgradeCidV0InOutput.Name()].(bool)
e := cidenc.Default()
......
......@@ -100,7 +100,7 @@ The CLI will exit with one of the following values:
// global options, added to every command
cmdenv.OptionCidBase,
cmdenv.OptionForceCidBase,
cmdenv.OptionUpgradeCidV0InOutput,
cmds.OptionEncodingType,
cmds.OptionStreamChannels,
......
......@@ -292,20 +292,20 @@ test_add_cat_file() {
test_cmp expected oh_actual
'
test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false succeeds" '
test_expect_success "ipfs add --cid-base=base32 --upgrade-cidv0-in-output=false succeeds" '
echo "base32 test" >mountdir/base32-test.txt &&
ipfs add --cid-base=base32 --force-cid-base=false mountdir/base32-test.txt >actual
ipfs add --cid-base=base32 --upgrade-cidv0-in-output=false mountdir/base32-test.txt >actual
'
test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false output looks good" '
test_expect_success "ipfs add --cid-base=base32 --upgrade-cidv0-in-output=false output looks good" '
HASHv0=$(cid-fmt -v 0 -b z %s "$HASHb32") &&
echo "added $HASHv0 base32-test.txt" >expected &&
test_cmp expected actual
'
test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false --only-hash succeeds" '
ipfs add --cid-base=base32 --force-cid-base=false --only-hash mountdir/base32-test.txt > oh_actual
test_expect_success "ipfs add --cid-base=base32 --upgrade-cidv0-in-output=false --only-hash succeeds" '
ipfs add --cid-base=base32 --upgrade-cidv0-in-output=false --only-hash mountdir/base32-test.txt > oh_actual
'
test_expect_success "ipfs add --cid-base=base32 --force-cid-base=false --only-hash output looks good" '
test_expect_success "ipfs add --cid-base=base32 --upgrade-cidv0-in-output=false --only-hash output looks good" '
test_cmp expected oh_actual
'
......
......@@ -363,11 +363,11 @@ test_object_cmd() {
test_cmp expected_putOut actual_putOut
'
test_expect_success "'ipfs object put file.json --cid-base=base32 --force-cid-base=true' succeeds" '
ipfs object put --cid-base=base32 --force-cid-base=true ../t0051-object-data/testPut.json > actual_putOut
test_expect_success "'ipfs object put file.json --cid-base=base32 --upgrade-cidv0-in-output=true' succeeds" '
ipfs object put --cid-base=base32 --upgrade-cidv0-in-output=true ../t0051-object-data/testPut.json > actual_putOut
'
test_expect_success "'ipfs object put file.json --cid-base=base32 --force-cid-base=true' output looks good" '
test_expect_success "'ipfs object put file.json --cid-base=base32 --upgrade-cidv0-in-output=true' output looks good" '
HASH=$(ipfs cid base32 "QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD") &&
printf "added $HASH\n" > expected_putOut &&
test_cmp expected_putOut actual_putOut
......@@ -394,8 +394,8 @@ test_object_cmd() {
grep -q $(ipfs cid base32 $HASHv1) mixed.actual
'
test_expect_success "ipfs object links --cid-base=base32 --force-cid-base=true converts both links" '
ipfs object links --cid-base=base32 --force-cid-base=true $MIXED | awk "{print \$1}" | sort > links.actual &&
test_expect_success "ipfs object links --cid-base=base32 --upgrade-cidv0-in-output=true converts both links" '
ipfs object links --cid-base=base32 --upgrade-cidv0-in-output=true $MIXED | awk "{print \$1}" | sort > links.actual &&
echo $(ipfs cid base32 $HASHv1) > links.expected
echo $(ipfs cid base32 $HASHv0) >> links.expected
test_cmp links.actual links.expected
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment