[question] How to apply a patch in a cloned repository
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 1.7k
- Forks
- 408
- Ø Merge
- 2 T. 57 Min.
- Gemergte PRs (30 T.)
- 7
Beschreibung
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!
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, den regulären Patch-Workflow im Issue mit pygit2.Patch.create_from, pygit2.Diff.parse_diff, pygit2.init_repository und repo.apply zu vergleichen. Prüfe die entsprechende pygit2-Dokumentation und das Verhalten, um festzustellen, ob ein Patch ohne ein Git-Repository angewendet werden kann; als erledigt gilt die Aufgabe, wenn der unterstützte Workflow oder die Einschränkung klar festgestellt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- git, python
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100