Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
f31e6b61
Commit
f31e6b61
authored
Jan 08, 2019
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change --force-cid-base to --upgrade-cidv0-in-output.
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
parent
727aea1f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
14 deletions
+14
-14
core/commands/cmdenv/cidbase.go
core/commands/cmdenv/cidbase.go
+2
-2
core/commands/root.go
core/commands/root.go
+1
-1
test/sharness/t0040-add-and-cat.sh
test/sharness/t0040-add-and-cat.sh
+6
-6
test/sharness/t0051-object.sh
test/sharness/t0051-object.sh
+5
-5
No files found.
core/commands/cmdenv/cidbase.go
View file @
f31e6b61
...
...
@@ -10,7 +10,7 @@ import (
)
var
OptionCidBase
=
cmdkit
.
StringOption
(
"cid-base"
,
"Multibase encoding used for version 1 CIDs in output."
)
var
Option
ForceCidBase
=
cmdkit
.
BoolOption
(
"
force-cid-base"
,
"Force multibase prefix by upgrading CIDv0 to CIDv1
."
)
var
Option
UpgradeCidV0InOutput
=
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
[
Option
ForceCidBase
.
Name
()]
.
(
bool
)
upgrade
,
upgradeDefined
:=
req
.
Options
[
Option
UpgradeCidV0InOutput
.
Name
()]
.
(
bool
)
e
:=
cidenc
.
Default
()
...
...
core/commands/root.go
View file @
f31e6b61
...
...
@@ -100,7 +100,7 @@ The CLI will exit with one of the following values:
// global options, added to every command
cmdenv
.
OptionCidBase
,
cmdenv
.
Option
ForceCidBase
,
cmdenv
.
Option
UpgradeCidV0InOutput
,
cmds
.
OptionEncodingType
,
cmds
.
OptionStreamChannels
,
...
...
test/sharness/t0040-add-and-cat.sh
View file @
f31e6b61
...
...
@@ -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
'
...
...
test/sharness/t0051-object.sh
View file @
f31e6b61
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment