製作修補程式#

您在 scikit-image 中發現了一個錯誤或想更改的其他東西... — 太棒了!

您已經找到解決方法 — 更棒!

您想告訴我們 — 最棒了!

最簡單的方法是製作一個修補程式或一組修補程式。在這裡我們說明如何操作。製作修補程式是最簡單快捷的方法,但如果您要做的事情不只是簡單快速的修改,請考慮改為遵循 用於開發的 Git 模型。

製作修補程式#

概述#

# tell git who you are
git config --global user.email you@yourdomain.example.com
git config --global user.name "Your Name Comes Here"
# get the repository if you don't have it
git clone https://github.com/scikit-image/scikit-image.git
# make a branch for your patching
cd scikit-image
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

然後,將生成的修補程式檔案發送到 scikit-image 開發者論壇 — 我們將在此熱烈感謝您。

詳細說明#

  1. 告訴 git 您是誰,以便它可以標記您所做的提交

    git config --global user.email you@yourdomain.example.com
    git config --global user.name "Your Name Comes Here"
    
  2. 如果您還沒有,請複製 scikit-image 儲存庫

    git clone https://github.com/scikit-image/scikit-image.git
    cd scikit-image
    
  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'
    

    請注意 commit-am 選項。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
    

    將這些檔案發送到 scikit-image 開發者論壇

完成後,要切換回程式碼的主副本,只需返回 main 分支

git checkout main

從修補程式轉移到開發#

如果您發現您已經做了一些修補程式,並且您有一個或多個功能分支,您可能會想要切換到開發模式。您可以使用您擁有的儲存庫來執行此操作。

在 github 上 fork scikit-image 儲存庫 — 製作您自己的 scikit-image 副本(fork)。然後

# 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 git@github.com:your-user-name/scikit-image.git
# push up any branches you've made and want to keep
git push origin the-fix-im-thinking-of

然後,如果您願意,您可以遵循 開發流程