3-2. 開発ワークフロー
This content is not available in your language yet.
issue が決まったら、実際にコードを書いて PR を出すまでの流れを解説します。
flowchart TD s1["1. リポジトリを fork"] s2["2. fork を clone"] s3["3. 作業ブランチを作成"] s4["4. コードを変更"] s5["5. テストを書く・実行"] s6["6. コミット(GPG 署名必須)"] s7["7. fork にプッシュ"] s8["8. Pull Request を作成"] s1 --> s2 --> s3 --> s4 --> s5 --> s6 --> s7 --> s8
Step 1: リポジトリを Fork する
Section titled “Step 1: リポジトリを Fork する”GitHub 上で https://github.com/XRPLF/rippled を開き、右上の Fork ボタンを押します。これで自分のアカウント配下にコピーが作成されます。
Step 2: Fork を Clone する
Section titled “Step 2: Fork を Clone する”git clone https://github.com/<your-username>/rippled.git xrpld-testcd xrpld-test
# upstream(本家)を追加git remote add upstream https://github.com/XRPLF/rippled.gitgit remote -v# origin https://github.com/<your-username>/rippled.git (fetch)# upstream https://github.com/XRPLF/rippled.git (fetch)Step 3: 作業ブランチを作る
Section titled “Step 3: 作業ブランチを作る”必ず develop ブランチから作業ブランチを切ります(master や release ではありません)。
# upstream の最新を取得git fetch upstreamgit checkout -b <your-username>/fix-something upstream/developブランチ命名規則
Section titled “ブランチ命名規則”外部コントリビューターの場合、ブランチ名は以下の形式を使います:
<GitHub username>/<説明>例:
nabesan/fix-payment-path-bugnabesan/add-escrow-testnabesan/docs-update-build-guideStep 4: コードを変更する
Section titled “Step 4: コードを変更する”作業ブランチで変更を加えます。変更は1つの論理的な目的に集中させましょう。
# 変更したファイルを確認git statusgit diffStep 5: テストを書いて実行する
Section titled “Step 5: テストを書いて実行する”すべての変更にはテストが必要です。
cd .build
# 関連するテストだけ実行(高速)./xrpld --unittest Payment
# 全テストを実行./xrpld --unittest --unittest-jobs 4テストが通ることを確認してからコミットします。
Step 6: コミットする
Section titled “Step 6: コミットする”GPG 署名の設定
Section titled “GPG 署名の設定”xrpld への全コミットは GPG 署名が必須です。未設定の場合は先にセットアップしてください。
# GPG キーの確認gpg --list-secret-keys --keyid-format=long
# Git に GPG キーを設定git config --global user.signingkey <YOUR_KEY_ID>git config --global commit.gpgsign trueコミットメッセージの書き方
Section titled “コミットメッセージの書き方”xrpld は CONTRIBUTING.md の Good commit messages に沿ったコミットメッセージを推奨しています。一般的な書き方として How to Write a Git Commit Message も参考になります。
件名(50文字以内、命令形、末尾にピリオドなし)
本文(72文字で折り返し)何をしたか・なぜしたかを説明する。どうやったかではなく、何を・なぜを書く。
Closes #1234良い例:
Fix Payment path calculation for IOU-to-IOU transfer
When both source and destination currencies are IOUs from differentissuers, the path finder incorrectly excluded direct paths throughthe order book. This caused some valid payments to fail withtecPATH_DRY.
Closes #5678悪い例:
fix bugupdated payment.cppWIP命令形の書き方
Section titled “命令形の書き方”件名は「このコミットを適用すると、___する」と読めるように書きます。
| 悪い例 | 良い例 |
|---|---|
Fixed the bug | Fix the bug |
Adding test | Add test for Payment edge case |
Changes to escrow | Update EscrowFinish to handle expired condition |
コミット実行
Section titled “コミット実行”git add <変更ファイル>git commit -S -m "Fix Payment path calculation for IOU-to-IOU transfer"# -S で GPG 署名を付ける(commit.gpgsign=true なら省略可)コミットの粒度
Section titled “コミットの粒度”- 関連する変更は1つのコミットにまとめる(開発途中の
WIPコミットは後でsquash) - 複数の目的が混在する場合は分割する
Step 7: Fork にプッシュする
Section titled “Step 7: Fork にプッシュする”git push origin <your-username>/fix-somethingupstream との同期
Section titled “upstream との同期”作業中に develop が進んだ場合は、rebase で同期します:
git fetch upstreamgit rebase upstream/developpre-commit フックの設定(推奨)
Section titled “pre-commit フックの設定(推奨)”xrpld では clang-format や clang-tidy のチェックを pre-commit フックとして設定できます。
pip3 install pre-commitpre-commit installコミット時に自動でフォーマットチェックが走るようになります。