vpp gerrit提交patch过程

原文地址:https://blog.csdn.net/u010827484/article/details/82713687

准备环境

注册gerrit账号及环境配置

1、进入fdio gerrit登录页面

https://gerrit.fd.io/r/login/%23%2Fq%2Fstatus%3Aopen

fdio gerrit登录页面
2、点击Account signup / management注册账号
选择‘I need to create a Linux Foundation ID’进行账号注册
注册账号
也可以使用facebook、google等进行登录
3、使用刚注册号的账号登录,查看注册信息
注册信息
4、配置SSH、GPG
4.1、点击‘SSH Public Keys’,根据提示导入本地SSH公钥到gerrit,同时导入gerrit信息到本地know_hosts文件
导入SSH公钥

本地生成SSH公钥,把公钥导入gerrit:

root@ubuntu:/home/vpp# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:zmgT7iZq5ON4UpJr94Nrl13SmNcZqQLY66SXZjkvblk root@ubuntu
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|    o       .    |
|   . o     o     |
| .    + S o o    |
|o o  + E = o     |
| *  = % B        |
|oo==.^.o         |
|o==+X=*.         |
+----[SHA256]-----+
root@ubuntu:/home/vpp# cat ~/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCh2QXLuRsrkJniXCHgxkQmQ6Puw0hmmucOW7c0sVoVVVsByWOQbSGv4wIQWg87vwdLRbOgltBQreYP/jc1lABK9YAvXyDiq4npqxxarT4HXNfZmorXhK6l2mKuNFnQ3ROBW5xA49pKgXp3G+mfZwokI4xtud67ordqr7r1YR1ZnrnOKTWunONjeLREocwGujFPM7jvcIllyIg1PYkWfRC87M5BfTsNBtH31+61xgbhJRmQtGSWDhN9WWxuMbQVO2x156FeROu3J5wAewVdlSYvavEjVxwXFffG8jjVI7j1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX root@ubuntu

4.2、点击‘GPG Public Keys’,根据提示导入GPG到gerrit
导入GPG

本地制作GPG,使用默认值,一直回车就行,最后GPG需要本地的操作来生成随机数,打开浏览器进行一些操作就可以了:

root@ubuntu:/home/vpp# gpg --gen-key
gpg (GnuPG) 1.4.20; Copyright (C) 2015 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 
Key does not expire at all
Is this correct? (y/N) y

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
    "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"

Real name: zhanglimao
Email address: zhanglimao0017@gmail.com
Comment: 
You selected this USER-ID:
    "zhanglimao <zhanglimao0017@gmail.com>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.

You don't want a passphrase - this is probably a *bad* idea!
I will do it anyway.  You can change your passphrase at any time,
using this program with the option "--edit-key".

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

Not enough random bytes available.  Please do some other work to give
the OS a chance to collect more entropy! (Need 3 more bytes)
...+++++
+++++
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
.+++++
..+++++
gpg: key 5F17BBDC marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   2048R/5F17BBDC 2018-09-15
      Key fingerprint = 9C99 9A25 26AF A7C8 4806  255F 4873 868C 5F17 BBDC
uid                  zhanglimao <zhanglimao0017@gmail.com>
sub   2048R/732E0435 2018-09-15

root@ubuntu:/home/vpp#

根据‘pub 2048R/5F17BBDC 2018-09-15’中的参数导出公钥,最后再导入到gerrit:

root@ubuntu:/home/vpp# gpg --export -a 5F17BBDC
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1

mQENBFuckh0BCADTwQeV9OITeidP10OcNlBFxousQCwNi+GJ+rMe0InN4KaeiRNW
Ze/XnI7YVROiXLoVmaxdMsUFc9sB7iWQaeHC+YYYv8fnKGwpYJhJ898sq0WTJvaX
bl1l+sJadOvMPDrwhkX4JF0RZWaFSoEOtp+sbyuzp7zkHulJ3Lw35a9FsyQK4+Rj
C3iJLQxjihZ9Ea4k0m5+rZbogHzQadPgHWDsZrLDfHX+HXq9Vx+0OpdklzRhnB6B
SGTyr2kqcw33zKTbHuiq0ua0lKekUwlN7O+a3gSrG86VLWOZfMt+WWWPT3Kckj9z
dVgZiWkOUxsPm3ei7uzlQx7ze85LvHekBMsjABEBAAG0JXpoYW5nbGltYW8gPHpo
YW5nbGltYW8wMDE3QGdtYWlsLmNvbT6JATgEEwECACIFAluckh0CGwMGCwkIBwMC
BhUIAgkKCwQWAgMBAh4BAheAAAoJEEhzhoxfF7vcd2sH/0SOJpDVbqRQLHQryQLH
3WO59dhWPJWlHTIzWcJWHTl16pEPCBeNoHWYpniLuUcpQr8gRaqmU+SbfQoLpx3L
CHPpO6VRGuSKCGjkvbBcP0XcjJZBc7zDKj1NIsy5o4wXWlFmGUu5M2ywkLpbqjxI
+kdDirye5VYB+HXo5Ig1WcfAANngzmuRupHQ46tfo3Z5DuEodtDNdoa5E/J8lKtq
4Xgu/jv7vEgIeom8OrCPsutxp+ZgbU816M1YxCUgUHIuAl1kl2r6gCcciJTluQbz
omEnKDM3tlzVHbHOGTwvi2ycckWOg1kzhqnL2WzBAsjCkTGmE8yqmKrnZOgGBhnT
F825AQ0EW5ySHQEIAMa8vT+NMqF8XVycI4Brn5TlrrJYyVdg65O4tZJRZMMSnS+v
q6YLKQ/O6DoSAx6IxBMHCyDVhE8tngxGL9UQaAGBhO0Qv6dp93d4xa3c1w1ERWg6
ISIjTdgSC30KRGCdU/vDU0SajxFeWMXH/wmeTFFELkxXVnpxmuOR6PM50Fpo5nTA
mod6dZ2KuWjpup72heb7x/vZTZ5JDQVk2VVr0NVMUrXXr96OkuwKBWk3YZLORNR+
7Ku6h9J0PULPUY6UNFZz74WDVYdn7TwAMPY8NT6LxwY4vmtxZP6MdYopa9tp6GHC
wVCK4Y3CQu58G1lKzUa31iK1UmXyWHE0iTKWRSEAEQEAAYkBHwQYAQIACQUCW5yS
HQIbDAAKCRBIc4aMXxe73Mb/B/43orqqYvm9ehd6S5oOZ3XpODXAD1tVpbMl6Tiq
lfhAlaSOZgRhMR/LSm7sLDq0kEBqIEwT8wuxuN1B0I2oyXyVF/XJrW8J4yu1l64+
Kio91tBfwLZBSDiySe2/kFe43DqN3Yi+YpUxmt7XcGAenNUCX1Z6pVDnZt+oXqPn
TRTLORUcpw0WOj/l6BkWUwqaK5IwznXUbNNS1Gfr0dBmnlK3KzaoKdejpyQyeepD
2eCVio2SOGpyyKerp3dNoD82a39MhH1UvzeSdcK3PwyvHu8OyRBHBM3G1pOgK3V+
RcraBcU+x7ne+eju68HBFr3TvJAjyMgsG9L8394SORVRgvrV
=gJjf
-----END PGP PUBLIC KEY BLOCK-----

下载vpp源码:

git clone https://gerrit.fd.io/r/vpp

安装git-review

apt-get install git-review

提交代码到本地GIT仓库

修改vpp源码,然后提交代码到GIT本地仓库。
1、git status查看本地修改的代码:

root@ubuntu:/home/vpp# git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   src/plugins/nsh/nsh.c

no changes added to commit (use "git add" and/or "git commit -a")
root@ubuntu:/home/vpp#

2、git add添加本地修改到git本地仓库:

git add src/plugins/nsh/nsh.c 

再次查看git状态,已经没有git add的提示了:

root@ubuntu:/home/vpp# git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   src/plugins/nsh/nsh.c

root@ubuntu:/home/vpp# 

3、提交代码到GIT本地仓库,使用git commit命令:

root@ubuntu:/home/vpp# git commit -m "fix nsh map index error, it will cause vpp appear Segmentation fault when vpp process double packages"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'root@ubuntu.(none)')
root@ubuntu:/home/vpp#

GIT提示没有设置用户信息,按照提示进行设置:

root@ubuntu:/home/vpp# git config --global user.email zhanglimao0017@gmail.com
root@ubuntu:/home/vpp# git config --global user.name "zhanglimao"
root@ubuntu:/home/vpp#

再次提交代码到GIT本地仓库:

root@ubuntu:/home/vpp# git commit -m "fix nsh map index error, it will cause vpp appear Segmentation fault when vpp process double packages"
[master 1573665] fix nsh map index error, it will cause vpp appear Segmentation fault when vpp process double packages
 1 file changed, 1 insertion(+), 1 deletion(-)
root@ubuntu:/home/vpp#

提交成功

使用GIT提交代码到gerrit.fd.io

执行‘git push origin HEAD:refs/for/master’命令后首先填写在gerrit的用户名,然后在输入密码:

root@ubuntu:/home/vpp# git push origin HEAD:refs/for/master
Username for 'https://gerrit.fd.io': limao.zhang
Password for 'https://limao.zhang@gerrit.fd.io': 

Counting objects: 6, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 551 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5)
remote: Processing changes: refs: 1, done    
To https://gerrit.fd.io/r/vpp
 ! [remote rejected] HEAD -> refs/for/master (not Signed-off-by author/committer/uploader in commit message footer)
error: failed to push some refs to 'https://gerrit.fd.io/r/vpp'

出现错误提示没有‘Signed-off-by‘,这是因为commit代码到GIT本地仓库的时候没有加‘-s’导致的,重新提交代码到GIT本地仓库:

root@ubuntu:/home/vpp# git commit -s -m "fix nsh map index error, it will cause vpp appear Segmentation fault when vpp process double packages"
[master 7489335] fix nsh map index error, it will cause vpp appear Segmentation fault when vpp process double packages
 1 file changed, 1 insertion(+), 1 deletion(-)
root@ubuntu:/home/vpp#

查看GIT LOG,确定是否有Signed-off-by:

root@ubuntu:/home/vpp# git log 
commit 7489335b878ec4ca1b683defa8177dc65971d85f
Author: zhanglimao <zhanglimao0017@gmail.com>
Date:   Sat Sep 15 13:19:41 2018 +0800

    fix nsh map index error, it will cause vpp appear Segmentation fault when vpp process double packages

    Signed-off-by: zhanglimao <zhanglimao0017@gmail.com>

GIT回退:
1、git log查看需要回退版本的commit号
2、使用git reset –hard 加上commit号回退到指定地方

重新提交代码到gerrit

root@ubuntu:/home/vpp# git push origin HEAD:refs/for/master
Username for 'https://gerrit.fd.io': limao.zhang
Password for 'https://limao.zhang@gerrit.fd.io': 
Counting objects: 6, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 567 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5)
remote: Processing changes: refs: 1, done    
remote: ERROR: [7489335] missing Change-Id in commit message footer
remote: 
remote: Hint: To automatically insert Change-Id, install the hook:
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 limao.zhang@gerrit.fd.io:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote:   git commit --amend
remote: 
To https://gerrit.fd.io/r/vpp
 ! [remote rejected] HEAD -> refs/for/master ([7489335] missing Change-Id in commit message footer)
error: failed to push some refs to 'https://gerrit.fd.io/r/vpp'

提示没有‘Change-Id’,按照错误提示首先执行:

gitdir=$(git rev-parse --git-dir); scp -p -P 29418 limao.zhang@gerrit.fd.io:hooks/commit-msg ${gitdir}/hooks/

然后再执行命令:

git commit --amend

执行‘git commit –amend’命令后会进入后commit编辑框,直接退出就可以添加‘Change-Id’

执行‘git log’查看‘Change-Id’是否添加成功:

root@ubuntu:/home/vpp# git log 
commit 5cb7dc6f5f3a9bf8ca78efa1206178c087e454fe
Author: zhanglimao <zhanglimao0017@gmail.com>
Date:   Sat Sep 15 13:19:41 2018 +0800

    fix nsh map index error, it will cause vpp appear Segmentation fault when vpp process double packages

    Change-Id: Ib32bb351356b84aaf696c57398610b52a5a1f4dd
    Signed-off-by: zhanglimao <zhanglimao0017@gmail.com>

重新提交代码到gerrit:

root@ubuntu:/home/vpp# git push origin HEAD:refs/for/master
Username for 'https://gerrit.fd.io': limao.zhang
Password for 'https://limao.zhang@gerrit.fd.io': 
Counting objects: 6, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 609 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5)
remote: Processing changes: new: 1, refs: 1, done    
remote: (W) 5cb7dc6: commit subject >50 characters; use shorter first paragraph
remote: (W) 5cb7dc6: too many commit message lines longer than 72 characters; manually wrap lines
remote: 
remote: New Changes:
remote:   https://gerrit.fd.io/r/14834 fix nsh map index error, it will cause vpp appear Segmentation fault when ...
remote: 
To https://gerrit.fd.io/r/vpp
 * [new branch]      HEAD -> refs/for/master

提交成功

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值