[question] How to apply a patch in a cloned repository
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 408
- Avg merge
- 2d 57m
- Merged PRs (30d)
- 7
Description
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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the regular patch workflow in the issue with pygit2.Patch.create_from, pygit2.Diff.parse_diff, pygit2.init_repository, and repo.apply. Check the corresponding pygit2 documentation and behavior to determine whether a patch can be applied without a Git repository; done means the supported workflow or limitation is clearly established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100