Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
blockchain_guide
提交
8895fe93
B
blockchain_guide
项目概览
OpenDocCN
/
blockchain_guide
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
blockchain_guide
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8895fe93
编写于
12月 13, 2016
作者:
Y
yeasy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updates hyperledger/contribute.md
上级
9ade7f28
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
136 addition
and
1 deletion
+136
-1
SUMMARY.md
SUMMARY.md
+2
-1
hyperledger/contribute.md
hyperledger/contribute.md
+134
-0
未找到文件。
SUMMARY.md
浏览文件 @
8895fe93
...
...
@@ -55,12 +55,13 @@
*
[
架构设计
](
hyperledger/arch.md
)
*
[
消息协议
](
hyperledger/message.md
)
*
[
链上代码
](
hyperledger/chaincode.md
)
*
[
贡献代码
](
hyperledger/contribute.md
)
*
[
链码示例一:信息公证
](
hyperledger/chaincode_example01.md
)
*
[
链码示例二:交易资产
](
hyperledger/chaincode_example02.md
)
*
[
链码示例三:数字货币发行与管理
](
hyperledger/chaincode_example03.md
)
*
[
链码示例四:学历认证
](
hyperledger/chaincode_example04.md
)
*
[
链码示例五:社区能源共享
](
hyperledger/chaincode_example05.md
)
*
[
链码示例六:物流供应链
](
hyperledger/chaincode_example06
.md
)
*
[
contribute
](
hyperledger/contribute
.md
)
*
[
小结
](
hyperledger/summary.md
)
*
[
Ethereum - 以太坊
](
ethereum/README.md
)
*
[
简介
](
ethereum/intro.md
)
...
...
hyperledger/contribute.md
0 → 100644
浏览文件 @
8895fe93
## 贡献代码
### 安装环境
推荐在 Ubuntu 14.04+ 环境中开发代码,并安装如下工具。
*
git:用来获取代码;
*
golang 1.6+:安装成功后配置 $GOPATH 等环境变量。
### 获取代码
首先注册 Linux foundation ID,并登陆
[
https://gerrit.hyperledger.org/
](
https://gerrit.hyperledger.org/
)
,添加个人 ssh pub key。
查看项目列表,找到对应项目,以 fabric 为例,获取
`Clone with commit-msg hook`
的方式。
典型的,执行如下命令获取代码,其中
`LF_ID`
替换为你的 Linux foundation id。
```
sh
$
git clone ssh://LF_ID@gerrit.hyperledger.org:29418/fabric
&&
scp
-p
-P
29418 LF_ID@gerrit.hyperledger.org:hooks/commit-msg fabric/.git/hooks/
```
如果没有添加个人 ssh pubkey,则可以通过 https 方式 clone,需要输入用户名和密码信息。
```
sh
git clone http://LF_ID@gerrit.hyperledger.org/r/fabric
&&
(
cd
fabric
&&
curl
-kLo
`
git rev-parse
--git-dir
`
/hooks/commit-msg http://LF_ID@gerrit.hyperledger.org/r/tools/hooks/commit-msg
;
chmod
+x
`
git rev-parse
--git-dir
`
/hooks/commit-msg
)
```
clone 下代码后,为了方便后面的编译测试,需要放到
`$GOPATH/src/github.com/hyperledger/`
路径下。
```
sh
$
mkdir
```
### 编译和测试
大部分编译和安装过程都可以通过 Makefile 来执行。
#### 安装 go tools
执行
```
sh
$
make gotools
```
#### 语法格式检查
执行
```
sh
$
make linter
```
#### 编译 peer
执行
```
sh
$
make peer
```
#### 生成 Docker 镜像
执行
```
sh
$
make images
```
#### 执行单元测试
执行
```
sh
$
make unit-test
```
如果要运行某个特定单元测试,则可以通过类似如下格式。
```
sh
$
go
test
-v
-run
=
TestGetFoo
```
#### 执行 BDD 测试
需先生成本地 Docker 镜像。
执行
```
sh
$
make behave
```
### 提交代码
仍然使用 Linux foundation ID 登录
[
jira.hyperledger.org
](
http://jira.hyperledger.org
)
,查看有没有未分配的任务,如果对某个任务感兴趣,可以添加自己为 assignee,如对 FAB-XXX 任务。
本地创建新的分支 FAB-XXX。
```
sh
$
git checkout
-b
FAB-XXX
```
实现任务代码,完成后,执行语法格式检查和测试等,确保所有检查和测试都通过。
提交代码到本地仓库。
```
sh
$
git commit
-a
-s
```
会打开一个窗口需要填写 commit 信息,格式一般要求为:
```
Simple words to describe main change
This fixes #FAB-XXX.
A more detailed description can be here, with several
paragraphs and sentences...
```
之后使用 git review 命令推送到远端仓库。
```
sh
$
git review
```
提交成功后,可以打开
[
gerrit.hyperledger.org/r/
](
https://gerrit.hyperledger.org/r/
)
,查看自己最新提交的 patchset 信息,添加几位 reviewer。之后就是等待开发者团队的 review 结果,如果得到通过,则会被项目的 maintainer 们 merge 到主分支。否则还需要针对大家提出的建议进一步的修正。
修正过程跟提交代码过程类似,唯一不同是提交的时候使用
```
sh
$
git commit
-a
--amend
```
表示这个提交是对旧提交的一次修订。
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录