Skip to content

Commit e700c02

Browse files
committedJun 19, 2015
core/commands/publish: Allow explicit local node ID
Instead of raising "keychains not yet implemented" whenever we have an explicit node ID, only raise the error when the given node ID isn't the local node. This allows folks to use the more-general explicit-node-ID form in scripts and such now, as long as they use the local node name when calling those scripts. Also add a test for this case, and update the comment for the one-argument case to match the current syntax for extracting a multihash name string. License: MIT Signed-off-by: W. Trevor King <wking@tremily.us>
1 parent 370df8f commit e700c02

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed
 

‎core/commands/publish.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,19 @@ Publish an <ipfs-path> to another public key (not implemented):
7272
return
7373
}
7474

75+
var name string
7576
var pstr string
7677

7778
switch len(args) {
7879
case 2:
79-
// name = args[0]
80+
name = args[0]
8081
pstr = args[1]
81-
res.SetError(errors.New("keychains not yet implemented"), cmds.ErrNormal)
82-
return
82+
if name != n.Identity.Pretty() {
83+
res.SetError(errors.New("keychains not yet implemented"), cmds.ErrNormal)
84+
return
85+
}
8386
case 1:
84-
// name = n.Identity.ID.String()
87+
// name = n.Identity.Pretty()
8588
pstr = args[0]
8689
}
8790

‎test/sharness/t0100-name.sh

+12
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,16 @@ test_expect_success "resolve output looks good" '
5252
test_cmp output expected4
5353
'
5454

55+
# publish with an explicit node ID
56+
57+
test_expect_success "'ipfs name publish <local-id> <hash>' succeeds" '
58+
PEERID=`ipfs id --format="<id>"` &&
59+
ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish
60+
'
61+
62+
test_expect_success "publish with our explicit node ID looks good" '
63+
echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish &&
64+
test_cmp expected_node_id_publish actual_node_id_publish
65+
'
66+
5567
test_done

0 commit comments

Comments
 (0)
Please sign in to comment.