もし FuelPHP のバグを見つけたら (2)〜バグ修正コードを Pull Request するための準備


(2012/07/14) この一連の記事をまとめ加筆修正しアップデートした電子書籍をリリースしました。よろしければ、ご覧ください → 『FuelPHP に貢献する方法』

もし FuelPHP のバグを見つけたら の続きです。

今日は、2. の「バグを修正したコードを Pull Request する」方法について説明します。前の記事を読んでいない場合は、先に読むことをお薦めします。

コードを修正する前に

FuelPHP のバグを修正するわけですが、コードを修正する前に、以下の文書を読みましょう。

  1. コーディング標準 - 概要 - FuelPHP ドキュメント
  2. fuel/CONTRIBUTING.md at 1.1/master · fuel/fuel · GitHub
  3. fuel/TESTING.md at 1.1/master · fuel/fuel · GitHub
  4. 貢献 - FuelPHP ドキュメント

とくに、まず、コーディング標準はしっかりと読んで、コーディング標準に準拠したコードを書く必要があります。

Developer's Certificate of Origin (DCO) とは?

fuel/CONTRIBUTING.md at 1.1/master · fuel/fuel · GitHub に「Developer's Certificate of Origin 1.1」というものがありますが、これは何でしょう?

簡単に言うと、提供するコードが FuelPHP に取り込まれても法的に問題がないということを、コード提供者 (コントリビュータ) が宣誓するということです。私の提供するコードは他人の知的財産権を侵害していないですよ、と。

問題となるコードが FuelPHP に取り込まれるのを防ぐためのものです。

もともと Linux kernel の開発で採用された仕組みです。JF にその解説の文書がありますので引用しておきます。

http://sourceforge.jp/projects/linuxjf/wiki/SubmittingPatches/attach/SubmittingPatches.txt より。

12) Sign your work

12) パッチへの署名

To improve tracking of who did what, especially with patches that can
percolate to their final resting place in the kernel through several
layers of maintainers, we've introduced a "sign-off" procedure on
patches that are being emailed around.

誰が何をしたのかを追いかけやすくするために (特に、パッチが何人かの
メンテナを経て最終的に Linux カーネルに取り込まれる場合のために)、電子
メールでやり取りされるパッチに対して「 sign-off 」という手続きを導入し
ました。

The sign-off is a simple line at the end of the explanation for the
patch, which certifies that you wrote it or otherwise have the right to
pass it on as a open-source patch.  The rules are pretty simple: if you
can certify the below:

「 sign-off 」とは、パッチがあなたの書いたものであるか、あるいは、
あなたがそのパッチをオープンソースとして提供する権利を保持している、
という証明をパッチの説明の末尾に一行記載するというものです。
ルールはとても単純です。以下の項目を確認して下さい。

        Developer's Certificate of Origin 1.1

        原作者の証明書( DCO ) 1.1

        By making a contribution to this project, I certify that:

        このプロジェクトに寄与するものとして、以下のことを証明する。

        (a) The contribution was created in whole or in part by me and I
            have the right to submit it under the open source license
            indicated in the file; or

        (a) 本寄与は私が全体又は一部作成したものであり、私がそのファイ
            ル中に明示されたオープンソースライセンスの下で公開する権利
            を持っている。もしくは、

        (b) The contribution is based upon previous work that, to the best
            of my knowledge, is covered under an appropriate open source
            license and I have the right under that license to submit that
            work with modifications, whether created in whole or in part
            by me, under the same open source license (unless I am
            permitted to submit under a different license), as indicated
            in the file; or

        (b) 本寄与は、私が知る限り、適切なオープンソースライセンスでカバ
            ーされている既存の作品を元にしている。同時に、私はそのライセ
            ンスの下で、私が全体又は一部作成した修正物を、ファイル中で示
            される同一のオープンソースライセンスで(異なるライセンスの下で
            投稿することが許可されている場合を除いて)投稿する権利を持って
            いる。もしくは、

        (c) The contribution was provided directly to me by some other
            person who certified (a), (b) or (c) and I have not modified
            it.

        (c) 本寄与は(a)、(b)、(c)を証明する第3者から私へ直接提供された
            ものであり、私はそれに変更を加えていない。

	(d) I understand and agree that this project and the contribution
	    are public and that a record of the contribution (including all
	    personal information I submit with it, including my sign-off) is
	    maintained indefinitely and may be redistributed consistent with
	    this project or the open source license(s) involved.

            私はこのプロジェクトと本寄与が公のものであることに理解及び同意す
            る。同時に、関与した記録(投稿の際の全ての個人情報と sign-off を
            含む)が無期限に保全されることと、当該プロジェクト又は関連する
            オープンソースライセンスに沿った形で再配布されることに理解及び
            同意する。

then you just add a line saying

もしこれに同意できるなら、以下のような1行を追加してください。

	Signed-off-by: Random J Developer <random@developer.example.org>

using your real name (sorry, no pseudonyms or anonymous contributions.)

実名を使ってください。(残念ですが、偽名や匿名による寄与はできません。)

Some people also put extra tags at the end.  They'll just be ignored for
now, but you can do this to mark internal company procedures or just
point out some special detail about the sign-off.

人によっては sign-off の近くに追加のタグを付加しています。それらは今のところ
無視されますが、あなたはそのタグを社内の手続きに利用したり、sign-off に特別
な情報を示したりすることができます。

FuelPHP の DCO は Linux のものそのままですので、上記の日本語訳を読めば内容は理解できると思います。

また、Signed-off-by: は、Git のコミットメッセージに記載します。

Git では、この sign-off のための --signoff (または -s) オプションが用意されていますので、

$ git commit -s

のようにコミットすれば、コミットメッセージに自動的に Signed-off-by: が追加されます。

なお、fuel/CONTRIBUTING.md at 1.1/master · fuel/fuel · GitHub には、

$ git config --global alias.commit 'commit -s'

のように commit のエリアスを commit -s にするという方法が記載されていますが、Git ではもともとのコマンドをエリアスによって変更することはできないので、これはうまく動作しないように思います。手許の環境では、上記のようなことはできませんでした。

もし FuelPHP のバグを見つけたら (3)」へ続く。