パッチの送信方法

    From The Document Foundation Wiki
    This page is a translated version of the page Development/gerrit/SubmitPatch and the translation is 62% complete.
    Outdated translations are marked like this.

    gerritで査読用パッチを送信する

    査読用パッチの送信

    Stephan Bergmann gave a helpful presentation in FOSDEM 2021 called The Perfect Gerrit Patch - a consumer report.

    Important: there is normally never a reason to abandon your patch. Please read carefully the section about submitting a new version.

    それでは、変更点(パッチ)を作成し、査読のためにgerritに送信してください(公式gerritドキュメントはこちら):

    git checkout -b <任意のローカルブランチ名> origin/master
    # コードを変更して、それがビルドできることを確認してください
    git add file1 <span class="mw-translate-fuzzy">[file ...] # 新しいファイル _と_ 変更したファイルを全て</span>
    git commit
    ./logerrit submit master

    注意:`logerrit`コマンドが動くようにするため、確実にgerritのセットアップをしてください。 ガイドはここにあります。

    The first command creates a new branch, and makes it track origin/master remote branch. This allows following ./g pull -r to rebase your branch automatically on the latest master, which may be a necessary precondition to submit, when your branch gets older than a week.

    If you had created a branch without specifying a remote branch to track, and now ./g pull -r doesn't rebase the branch automatically, you may also use command git branch -u origin/master on an existing branch to start tracking.

    注意: git add + git commit ステップは'git gui'でも行うことができますが、コミットの題名行は72文字以下で、(もしあれば)コミットメッセージ行は80文字以下であることに注意してください。

    注意:masterへの投稿において、現在のmasterのバージョンでの変更の(リ)ベースは有用です。これによってjenkins上でのCIビルドでccacheの恩恵を多く受けることができます。

    少なくとも最後の行は特別で、この行で名前付きローカルブランチのすべてのパッチが、査読キューのmasterブランチにpushされます(リリースブランチやほかのブランチに送信したいならば適宜修正してください)。普通の貢献者はパッチのメールアドレスがgerritアカウントと同一でないとpushが許可されません。

    If you have some version preinstalled, you might not see warnings (but have inconsistent results when buildbots would fail telling you to change formatting the other way), or the preinstalled version might not work (e.g., complaining about command line options). The version used by LibreOffice may be found at https://dev-www.libreoffice.org/bin/.

    少なくとも最後の行は特別で、この行で名前付きローカルブランチのすべてのパッチが、査読キューのmasterブランチにpushされます(リリースブランチやほかのブランチに送信したいならば適宜修正してください)。普通の貢献者はパッチのメールアドレスがgerritアカウントと同一でないとpushが許可されません。

    pushに成功したら、gitはあなたのコミットが査読待ちのどこにいるのかを報告します。URLは以下のようなものになります: https://gerrit.libreoffice.org/#/c/229/.

    査読中はローカルブランチを保持したままのほうが良いでしょう。それによって、パッチの新しいバージョンを簡単にpushできるようになります。 その間は以下のコードを実行することで

    git checkout master

    masterブランチに戻ることができます - そして上記の操作(ローカルブランチの作成、コーディング、コミット、gerritへのpush)でほかのパッチを再び編集することができます。

    貢献者リストにあなたを追加する

    もし初めてLibreOfficeプロジェクトにパッチを送るのであれば、開発者と貢献者リストにあなたを追加し(そこの指示に従ってください)、あなたの貢献のライセンスを表明してください。

    Please only send the statement no earlier than when you post your first submission to gerrit and ensure you have permission from your parents!

    パッチ送信の追加情報

    上記の方法の代わりに、Development/GitReviewでの説明の通り、"git review"を使うこともできます。

    Reviewing patches

    The next step after submitting a patch is collaboratively reviewing it on gerrit. See Development/gerrit/PatchReview to learn more.

    パッチ送信の詳細についての話題

    新しいバージョンの送信

    パッチの査読中にパッチの新しいバージョンを送信する必要があれば、以下のようにします:

    git checkout <div lang="en" dir="ltr" class="mw-content-ltr">
    <local_branch_associated_with_your_patch>
    <do your modification>
    </div>
    git add ...
    git commit --amend  # これはブランチ上で新しいコミットを作成する代わりに最後のコミットを変更します
    ./logerrit submit master

    補足: gerritは(コミットメッセージを最初に送信した際に、自動的に挿入されたChange-Id行によって)既存の変更点(パッチ)の新しいバージョンであることを認識します。

    Tip.svg

    Tip:
    もし--amendを使うことを忘れて2つのコミットができてしまったら、git rebase -iでそれらをマージすることができます:方法はLibreOffice開発者のためのGitをご覧下さい。


    変更点の追記・新しいバージョンのパッチ送信のためのGit reviewの使用

    上記の方法を使った手動での変更点の追記は混乱しやすく、あなたのパッチに関連したローカルブランチを追い続けるとエラーが発生しやすくなります(何かに関連?)。gerritへいくつか変更を送信するならば、masterブランチでそれら全てを保持し、個別に追加することが重要です。送信や新しいパッチセットのダウンロード・変更・追記・送信・リセットを行うたびにHEAD^へリセットするか、個別のブランチでそれを行う必要があるでしょう。その際はgit reviewが簡単にしてくれます。

    その方法はDevelopment/GitReview#Amending_a_gerrit_changeを読んでください。

    Submitting patches as private or work-in-progress

    If you use ./logerrit submit master%private instead of ./logerrit submit master, you will create a private change.

    Such a change will only be visible to yourself and whoever you add as a reviewer with the 'add reviewer' button in gerrit.

    If you don't need to hide your change from the general public, you can use ./logerrit submit master%wip to create a work-in-progress change.

    If you are not using logerrit, push to refs/for/branch%private or refs/for/branch%wip.

    You can also toggle the private and WIP states from the gerrit UI.

    辞書・helpcontent2・翻訳のサブモジュールの査読用パッチの送信

    サブモジュールのページをご覧ください。

    Cherry picking yourself out of trouble

    Ignoring the advice about submitting new versions of patches is common. This might lead to deleting a local branch or submitting a new patch depending on an older patch. In order to work on your original patch locally again, do the following:

    1. In a terminal, check out a new branch from master
    2. Click the kebab menu in the top right corner of the Gerrit patch view
    3. Select Download patch
    4. Click the copy button next to Cherry Pick
    5. Paste the copied command into your terminal
    6. Follow the modifying and amending advice from the section about submitting a new version