LoginSignup
17
16

More than 5 years have passed since last update.

OpenStackにコードをマージするまでの道のり

Posted at

はじめに

本家gitかgithubのミラーから必要なリポジトリをcloneしてくる。ここでは、openstack-manualsでBugを改修するシナリオを例に実施する。なお、今回OSはCentOS6を利用している。ここでは説明しないが、LaunchpadとGerritをリンクさせておく必要もある。

$ git clone https://github.com/openstack/openstack-manuals.git
$ cd openstack-manual

gitの設定

git configを設定する。

$ git config gitreview.scheme https
$ git config gitreview.port 443
$ git config gitreview.username gerrit-test-user <= Gerritに登録されているusernameを入力
$ git config user.name "Taro Yamada"            <= Gerritに登録されているFull Nameを入力
$ git config user.email "xxxxx@yyyyy.com"        <= Gerritに登録されているアドレスを入力する

git-reviewツール導入と設定

OpenStack開発では、コードレビューシステムGerritを利用している。そこで、Gerritを使った作業の詳細全てを扱う git のサブコマンドであるgit-reviewツールを利用する必要がある。

EPEL導入が前提
$ sudo yum install -y git-review

デフォルトでは、sshで通信しようとするのでhttpsに変更するために以下の通りgit remote addする。

$ git remote add gerrit https://gerrit-test-user@review.openstack.org:443/openstack/openstack-manuals.git

ここまで設定してgit reviewコマンドを実行する。

$ git review -s -v
2015-07-17 10:20:13.935741 Running: git log --color=never --oneline HEAD^1..HEAD
2015-07-17 10:20:13.938975 Running: git remote
2015-07-17 10:20:13.941349 Running: git branch -a --color=never
Setting up gerrit branch tracking for better rebasing
2015-07-17 10:20:13.943823 Running: git remote update gerrit
Fetching gerrit
From https://review.openstack.org:443/openstack/openstack-manuals
 * [new branch]      master     -> gerrit/master
 * [new branch]      stable/juno -> gerrit/stable/juno
 * [new branch]      stable/kilo -> gerrit/stable/kilo
2015-07-17 10:20:16.200501 Running: git rev-parse --show-toplevel --git-dir
2015-07-17 10:20:16.203341 Running: git config --get remote.gerrit.url
2015-07-17 10:20:16.205546 Running: git config --get remote.gerrit.pushurl
Found origin Push URL: https://gerrit-test-user@review.openstack.org:443/openstack/openstack-manuals.git
Fetching commit hook from: https://gerrit-test-user@review.openstack.org:443/tools/hooks/commit-msg
2015-07-17 10:20:16.208040 Running: git config --bool --get http.sslVerify

Branchを切る

LaunchpadのBug番号を元に、bug/${bug-number}という命名規則に沿ってBranchを切る。

$ git checkout -b bug/123456789

Bugを改修する

このタイミングで必要な改修を全て施す。

コミットとレビューを行う

改修が終われば、以下のコマンドでコミットする。ここで重要なことはコミットメッセージはとても大切だということである。

$ git add --all
$ git commit

git commitを実行すればviが起動して(もしかしたら、nanoが起動するかもしれない)、コミットメッセージを書くことができる。

  1. 1行目にはLaunchpadに登録されているBugのタイトルを入れる。
  2. 2行目は改行する。
  3. 3行目以降にBugの内容を記述する。
    • ここで注意したいことは、ドキュメント以外のコンポーネントのソースコートを改修して、かつドキュメントの改修も必要である場合には、DocImpactという文字列を含める必要がある、ということである。
  4. 最終行にこのコミットに対応するLaunchpadのバグナンバーをいれることである。
Launchpadに登録されているBugのTitle

コミットメッセージを入れる
DocImpact     <= 必要な場合入れる

Closes-Bug: #123456789

コミットが終われば、git reviewをする。

$ git review
Password for 'https://gerrit-test-user@review.openstack.org:443': <= Gerritの設定ページのHTTP Passwordの項目にあるパスワードを入力
remote: Resolving deltas: 100% (4/4)
remote: Processing changes: new: 1, refs: 1, done
remote:
remote: New Changes:
remote:   https://review.openstack.org/987654321
remote:
To https://gerrit-test-user@review.openstack.org:443/openstack/openstack-manuals.git
 * [new branch]      HEAD -> refs/publish/master/bug/123456789

そうすると、自動でLaunchpadに以下のようなコメントがつく。

OpenStack Infra (hudson-openstack) wrote 1 minute ago: Fix proposed to openstack-manuals (master)

Fix proposed to branch: master
Review: https://review.openstack.org/987654321

ここで表示されるReview:のURLがGerritのURLである。自動でテストが実行されるので、Zuul Statusから自分のテストのStatusをチェックすることができる。このページで自分のGerritのIDを検索すればよい。

レビューとマージ

テストに通過すれば、各コンポーネントのCore Developerがレビューしてくれる。Core Developer 2名から2ポイントずつ取得すればコードがマージされる。

ちなみに、レビューで追加で指摘されたり、再度改修が必要になった場合には、改修後に以下のコマンドを実行して再度テストを実行する。あと、必ずGerritのReplyの項目から指摘してくれた人に感謝の言葉を述べよう。

$ git add --all
$ git commit --amend

再度、git reviewをする。

$ git review
Password for 'https://gerrit-test-user@review.openstack.org:443':
remote: Resolving deltas: 100% (7/7)
remote: Processing changes: updated: 1, refs: 1, done
To https://gerrit-test-user@review.openstack.org:443/openstack/openstack-manuals.git
 * [new branch]      HEAD -> refs/publish/master/bug/123456789

あとは、マージされるのを待つのみ。

17
16
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
16