Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
0f909cb2
提交
0f909cb2
authored
10月 17, 2015
作者:
Juan Benet
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1853 from CaioAlonso/show-commit-hash
Adds the option to see the current git commit with `ipfs version --commit`
上级
4de5eaad
e05f2d37
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
23 行增加
和
4 行删除
+23
-4
Makefile
Makefile
+3
-1
Makefile
cmd/ipfs/Makefile
+3
-1
version.go
core/commands/version.go
+15
-2
version.go
repo/config/version.go
+2
-0
没有找到文件。
Makefile
浏览文件 @
0f909cb2
...
@@ -5,6 +5,8 @@ else
...
@@ -5,6 +5,8 @@ else
go_test
=
go
test
go_test
=
go
test
endif
endif
commit
=
`
git rev-parse
--short
HEAD
`
ldflags
=
"-X "
github.com/ipfs/go-ipfs/repo/config
".CurrentCommit=
$(commit)
"
all
:
all
:
# no-op. try:
# no-op. try:
...
@@ -24,7 +26,7 @@ install:
...
@@ -24,7 +26,7 @@ install:
cd
cmd/ipfs
&&
go install
cd
cmd/ipfs
&&
go install
build
:
build
:
cd
cmd/ipfs
&&
go build
-i
cd
cmd/ipfs
&&
go build
-i
-ldflags
=
$(ldflags)
nofuse
:
nofuse
:
cd
cmd/ipfs
&&
go install
-tags
nofuse
cd
cmd/ipfs
&&
go install
-tags
nofuse
...
...
cmd/ipfs/Makefile
浏览文件 @
0f909cb2
all
:
install
all
:
install
commit
=
`
git rev-parse
--short
HEAD
`
ldflags
=
"-X "
github.com/ipfs/go-ipfs/repo/config
".CurrentCommit=
$(commit)
"
build
:
build
:
go build
go build
-ldflags
=
$(ldflags)
install
:
build
install
:
build
go install
go install
core/commands/version.go
浏览文件 @
0f909cb2
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
type
VersionOutput
struct
{
type
VersionOutput
struct
{
Version
string
Version
string
Commit
string
}
}
var
VersionCmd
=
&
cmds
.
Command
{
var
VersionCmd
=
&
cmds
.
Command
{
...
@@ -21,24 +22,36 @@ var VersionCmd = &cmds.Command{
...
@@ -21,24 +22,36 @@ var VersionCmd = &cmds.Command{
Options
:
[]
cmds
.
Option
{
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"number"
,
"n"
,
"Only show the version number"
),
cmds
.
BoolOption
(
"number"
,
"n"
,
"Only show the version number"
),
cmds
.
BoolOption
(
"commit"
,
"Show the commit hash"
),
},
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
res
.
SetOutput
(
&
VersionOutput
{
res
.
SetOutput
(
&
VersionOutput
{
Version
:
config
.
CurrentVersionNumber
,
Version
:
config
.
CurrentVersionNumber
,
Commit
:
config
.
CurrentCommit
,
})
})
},
},
Marshalers
:
cmds
.
MarshalerMap
{
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
v
:=
res
.
Output
()
.
(
*
VersionOutput
)
v
:=
res
.
Output
()
.
(
*
VersionOutput
)
commit
,
found
,
err
:=
res
.
Request
()
.
Option
(
"commit"
)
.
Bool
()
commitTxt
:=
""
if
err
!=
nil
{
return
nil
,
err
}
if
found
&&
commit
{
commitTxt
=
"-"
+
v
.
Commit
}
number
,
found
,
err
:=
res
.
Request
()
.
Option
(
"number"
)
.
Bool
()
number
,
found
,
err
:=
res
.
Request
()
.
Option
(
"number"
)
.
Bool
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
found
&&
number
{
if
found
&&
number
{
return
strings
.
NewReader
(
fmt
.
Sprintln
(
v
.
Version
)),
nil
return
strings
.
NewReader
(
fmt
.
Sprintln
(
v
.
Version
+
commitTxt
)),
nil
}
}
return
strings
.
NewReader
(
fmt
.
Sprintf
(
"ipfs version %s
\n
"
,
v
.
Version
)),
nil
return
strings
.
NewReader
(
fmt
.
Sprintf
(
"ipfs version %s%s
\n
"
,
v
.
Version
,
commitTxt
)),
nil
},
},
},
},
Type
:
VersionOutput
{},
Type
:
VersionOutput
{},
...
...
repo/config/version.go
浏览文件 @
0f909cb2
...
@@ -9,6 +9,8 @@ import (
...
@@ -9,6 +9,8 @@ import (
// CurrentVersionNumber is the current application's version literal
// CurrentVersionNumber is the current application's version literal
const
CurrentVersionNumber
=
"0.3.8-dev"
const
CurrentVersionNumber
=
"0.3.8-dev"
// CurrentCommit is the current git commit, this is set as a ldflag in the Makefile
var
CurrentCommit
string
// Version regulates checking if the most recent version is run
// Version regulates checking if the most recent version is run
type
Version
struct
{
type
Version
struct
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论