libgit2 / libgit2/pygit2

[question] How to apply a patch in a cloned repository

オープン
#944 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
1.7k
フォーク
408
平均マージ
2日 57分
マージ済み PR(30日)
7

説明

Hi!

I would like to apply a regular patch file, but without a git repo. Is it possible using this project? For instance:

$ cd myproject/
$ patch < 0001-regular-fix.patch

I found two methods, but I'm not sure if they are what I want:

pygit2.Patch.create_from
pygit2.Diff.parse_diff

Actually I didn't find some easy to apply them. My idea was something like:

def apply_patch(working_folder, patch_file):
    with open(patch_file, 'rb') as fd:
        patch_content = fd.read()
    
        diff = pygit2.Diff.parse_diff(patch_content)
        repo = pygit2.init_repository(working_folder, bare=True)
        repo.apply(diff)

Regards!

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、issue内の通常のパッチワークフローを pygit2.Patch.create_from、pygit2.Diff.parse_diff、pygit2.init_repository、repo.apply と比較します。対応する pygit2 のドキュメントと動作を確認し、Git リポジトリなしでパッチを適用できるかどうかを判断します。サポートされるワークフローまたは制限が明確に確立されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
git, python
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。