Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
7e7fcb35
提交
7e7fcb35
authored
4月 16, 2016
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
changes from CR feedback
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
上级
73a2f80c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
12 行删除
+39
-12
diff.go
core/commands/object/diff.go
+25
-7
object.go
core/commands/object/object.go
+2
-2
t0052-object-diff.sh
test/sharness/t0052-object-diff.sh
+12
-3
没有找到文件。
core/commands/object/diff.go
浏览文件 @
7e7fcb35
...
...
@@ -15,6 +15,9 @@ var ObjectDiffCmd = &cmds.Command{
Tagline
:
"takes a diff of the two given objects"
,
ShortDescription
:
`
ipfs object diff is a command used to show the differences between
two ipfs objects.`
,
LongDescription
:
`
ipfs object diff is a command used to show the differences between
two ipfs objects.
Example:
...
...
@@ -38,6 +41,9 @@ Example:
cmds
.
StringArg
(
"obj_a"
,
true
,
false
,
"object to diff against"
),
cmds
.
StringArg
(
"obj_b"
,
true
,
false
,
"object to diff"
),
},
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"verbose"
,
"v"
,
"Produce verbose output"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
node
,
err
:=
req
.
InvocContext
()
.
GetNode
()
if
err
!=
nil
{
...
...
@@ -85,16 +91,28 @@ Example:
Type
:
[]
*
dagutils
.
Change
{},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
verbose
,
_
,
_
:=
res
.
Request
()
.
Option
(
"v"
)
.
Bool
()
changes
:=
res
.
Output
()
.
([]
*
dagutils
.
Change
)
buf
:=
new
(
bytes
.
Buffer
)
for
_
,
change
:=
range
changes
{
switch
change
.
Type
{
case
dagutils
.
Add
:
fmt
.
Fprintf
(
buf
,
"added new link %q pointing to %s
\n
"
,
change
.
Path
,
change
.
After
)
case
dagutils
.
Mod
:
fmt
.
Fprintf
(
buf
,
"changed %q from %s to %s
\n
"
,
change
.
Path
,
change
.
Before
,
change
.
After
)
case
dagutils
.
Remove
:
fmt
.
Fprintf
(
buf
,
"removed link %q (was %s)
\n
"
,
change
.
Path
,
change
.
Before
)
if
verbose
{
switch
change
.
Type
{
case
dagutils
.
Add
:
fmt
.
Fprintf
(
buf
,
"added new link %q pointing to %s
\n
"
,
change
.
Path
,
change
.
After
)
case
dagutils
.
Mod
:
fmt
.
Fprintf
(
buf
,
"changed %q from %s to %s
\n
"
,
change
.
Path
,
change
.
Before
,
change
.
After
)
case
dagutils
.
Remove
:
fmt
.
Fprintf
(
buf
,
"removed link %q (was %s)
\n
"
,
change
.
Path
,
change
.
Before
)
}
}
else
{
switch
change
.
Type
{
case
dagutils
.
Add
:
fmt
.
Fprintf
(
buf
,
"+ %s %q
\n
"
,
change
.
After
,
change
.
Path
)
case
dagutils
.
Mod
:
fmt
.
Fprintf
(
buf
,
"~ %s %s %q
\n
"
,
change
.
Before
,
change
.
After
,
change
.
Path
)
case
dagutils
.
Remove
:
fmt
.
Fprintf
(
buf
,
"- %s %q
\n
"
,
change
.
Before
,
change
.
Path
)
}
}
}
return
buf
,
nil
...
...
core/commands/object/object.go
浏览文件 @
7e7fcb35
...
...
@@ -49,25 +49,25 @@ var ObjectCmd = &cmds.Command{
directly.`
,
Synopsis
:
`
ipfs object data <key> - Outputs raw bytes in an object
ipfs object diff <key1> <key2> - Diffs two given objects
ipfs object get <key> - Get the DAG node named by <key>
ipfs object links <key> - Outputs links pointed to by object
ipfs object new <template> - Create new ipfs objects
ipfs object patch <args> - Create new object from old ones
ipfs object put <data> - Stores input, outputs its key
ipfs object stat <key> - Outputs statistics of object
ipfs object diff <key1> <key2> - Diffs two given objects
`
,
},
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"data"
:
ObjectDataCmd
,
"diff"
:
ObjectDiffCmd
,
"get"
:
ObjectGetCmd
,
"links"
:
ObjectLinksCmd
,
"new"
:
ObjectNewCmd
,
"patch"
:
ObjectPatchCmd
,
"put"
:
ObjectPutCmd
,
"stat"
:
ObjectStatCmd
,
"diff"
:
ObjectDiffCmd
,
},
}
...
...
test/sharness/t0052-object-diff.sh
浏览文件 @
7e7fcb35
...
...
@@ -37,12 +37,21 @@ test_expect_success "diff added link works" '
'
test_expect_success
"diff added link looks right"
'
echo + QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A \"cat\" > diff_exp &&
test_cmp diff_exp diff_out
'
test_expect_success
"verbose diff added link works"
'
ipfs object diff -v $A $B > diff_out
'
test_expect_success
"verbose diff added link looks right"
'
echo added new link \"cat\" pointing to QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A > diff_exp &&
test_cmp diff_exp diff_out
'
test_expect_success
"diff removed link works"
'
ipfs object diff $B $A > diff_out
ipfs object diff
-v
$B $A > diff_out
'
test_expect_success
"diff removed link looks right"
'
...
...
@@ -51,7 +60,7 @@ test_expect_success "diff removed link looks right" '
'
test_expect_success
"diff nested add works"
'
ipfs object diff $B $C > diff_out
ipfs object diff
-v
$B $C > diff_out
'
test_expect_success
"diff looks right"
'
...
...
@@ -60,7 +69,7 @@ test_expect_success "diff looks right" '
'
test_expect_success
"diff changed link works"
'
ipfs object diff $C $D > diff_out
ipfs object diff
-v
$C $D > diff_out
'
test_expect_success
"diff looks right"
'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论