パッチの作成#

Matplotlibでバグまたは変更したい何かを発見しました.. — 素晴らしい!

あなたはそれを修正する方法を考え出しました — さらに良いです!

あなたはそれについて私たちに伝えたいです—何よりも!

最も簡単な方法は、パッチまたはパッチのセットを作成することです。ここではその方法を説明します。パッチを作成するのが最も簡単で手っ取り早い方法ですが、単純な手っ取り早い作業以上のことを行う場合は、 代わりにGit for developmentモデルに従うことを検討してください。

パッチの作成#

概要#

# tell git who you are
git config --global user.email [email protected]
git config --global user.name "Your Name Comes Here"
# get the repository if you don't have it
git clone https://github.com/matplotlib/matplotlib.git
# make a branch for your patching
cd matplotlib
git branch the-fix-im-thinking-of
git checkout the-fix-im-thinking-of
# hack, hack, hack
# Tell git about any new files you've made
git add somewhere/tests/test_my_bug.py
# commit work in progress as you go
git commit -am 'BF - added tests for Funny bug'
# hack hack, hack
git commit -am 'BF - added fix for Funny bug'
# make the patch files
git format-patch -M -C main

次に、生成されたパッチ ファイルをMatplotlib メーリング リストに送信してください。

詳細に#

  1. 作成したコミットにラベルを付けることができるように、あなたが誰であるかを git に伝えます。

    git config --global user.email [email protected]
    git config --global user.name "Your Name Comes Here"
    
  2. まだ持っていない場合は、 Matplotlibリポジトリのコピーを複製します。

    git clone https://github.com/matplotlib/matplotlib.git
    cd matplotlib
    
  3. 「機能ブランチ」を作成します。これは、バグ修正に取り組む場所になります。これは素晴らしく安全で、メイン ブランチのコードの変更されていないコピーにアクセスできます。

    git branch the-fix-im-thinking-of
    git checkout the-fix-im-thinking-of
    
  4. いくつかの編集を行い、それらをコミットします。

    # hack, hack, hack
    # Tell git about any new files you've made
    git add somewhere/tests/test_my_bug.py
    # commit work in progress as you go
    git commit -am 'BF - added tests for Funny bug'
    # hack hack, hack
    git commit -am 'BF - added fix for Funny bug'
    

    -amのオプションに注意してくださいcommit。このmフラグは、コマンド ラインにメッセージを入力しようとしていることを示しているだけです。aフラグ — あなたはただ信じることができます — またはなぜ -a フラグなのかを見てください? .

  5. 終了したら、すべての変更をコミットしたことを確認します。

    git status
    
  6. 最後に、コミットをパッチにします。ブランチから分岐したため、すべてのコミットが必要ですmain

    git format-patch -M -C main
    

    コミット用に名前が付けられたいくつかのファイルが作成されます。

    0001-BF-added-tests-for-Funny-bug.patch
    0002-BF-added-fix-for-Funny-bug.patch
    

    これらのファイルをMatplotlib メーリング リストに送信します。

main完了したら、コードのメイン コピーに戻るには、ブランチに戻ります。

git checkout main

パッチ適用から開発への移行#

いくつかのパッチを適用し、機能ブランチが 1 つ以上ある場合は、おそらく開発モードに切り替えたいと思うでしょう。あなたが持っているリポジトリでこれを行うことができます。

github でMatplotlibリポジトリをフォークする— Matplotlibの独自のコピー (フォーク) を作成します。それで:

# checkout and refresh main branch from main repo
git checkout main
git pull origin main
# rename pointer to main repository to 'upstream'
git remote rename origin upstream
# point your repo to default read / write to your fork on github
git remote add origin [email protected]:your-user-name/matplotlib.git
# push up any branches you've made and want to keep
git push origin the-fix-im-thinking-of

その後、必要に応じて開発ワークフローに従うことができ ます。