patch-fixer 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patch-fixer
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Fixes erroneous git apply patches to the best of its ability.
5
5
  Maintainer-email: Alex Mueller <amueller474@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -30,27 +30,47 @@ Dynamic: license-file
30
30
  So you asked an LLM to generate a code diff, tried to apply it with `git apply`, and got a bunch of malformed patch errors? Well fear no more, `patch_fixer.py` is here to save the day... more or less.
31
31
 
32
32
  ## Installation
33
- ```
34
- git clone https://github.com/ajcm474/patch-fixer.git
35
- cd patch-fixer
36
- pip install -e .
33
+ ```bash
34
+ # Make sure you're using at least python 3.10
35
+ python -m venv .venv/
36
+ source .venv/bin/activate
37
+ pip install patch-fixer
37
38
  ```
38
39
 
39
40
  ## Usage
41
+ ### API:
42
+ ```python
43
+ >>> from patch_fixer import fix_patch
44
+ >>>
45
+ >>> patch_file = "/path/to/broken.patch"
46
+ >>> original = "/path/to/original/state" # file or directory being patched
47
+ >>> with open(patch_file, encoding="utf-8") as f:
48
+ ... patch_lines = f.readlines()
49
+ ...
50
+ >>> fixed_lines = fix_patch(patch_lines, original)
51
+ >>> output_file = "/path/to/fixed.patch"
52
+ >>>
53
+ >>> with open(output_file, 'w', encoding='utf-8') as f:
54
+ ... f.writelines(fixed_lines)
55
+ >>>
40
56
  ```
41
- python patch_fixer.py original broken.patch fixed.patch
57
+ ### Command line:
58
+ ```bash
59
+ python patch_fixer/patch_fixer.py original broken.patch fixed.patch
42
60
  ```
43
61
  where `original` is the file or directory you were trying to patch,
44
62
  `broken.patch` is the malformed patch generated by the LLM,
45
63
  and `fixed.patch` is the output file containing the (hopefully) fixed patch.
46
64
 
47
- ## Testing
48
- Assuming you've already cloned the repo:
49
- ```
65
+ ## Local Testing
66
+ ```bash
67
+ git clone https://github.com/ajcm474/patch-fixer.git
68
+ cd patch-fixer
50
69
  pip install -e .[test]
51
70
  pytest
52
71
  ```
53
- Note that some tests currently fail as this project is in the early alpha stage.
72
+ Note that some test failures are expected as this project is in the early alpha stage.
73
+ Please only report test failures if the same test passed in a previous version.
54
74
 
55
75
  ## License
56
76
 
@@ -0,0 +1,49 @@
1
+ # patch-fixer
2
+ So you asked an LLM to generate a code diff, tried to apply it with `git apply`, and got a bunch of malformed patch errors? Well fear no more, `patch_fixer.py` is here to save the day... more or less.
3
+
4
+ ## Installation
5
+ ```bash
6
+ # Make sure you're using at least python 3.10
7
+ python -m venv .venv/
8
+ source .venv/bin/activate
9
+ pip install patch-fixer
10
+ ```
11
+
12
+ ## Usage
13
+ ### API:
14
+ ```python
15
+ >>> from patch_fixer import fix_patch
16
+ >>>
17
+ >>> patch_file = "/path/to/broken.patch"
18
+ >>> original = "/path/to/original/state" # file or directory being patched
19
+ >>> with open(patch_file, encoding="utf-8") as f:
20
+ ... patch_lines = f.readlines()
21
+ ...
22
+ >>> fixed_lines = fix_patch(patch_lines, original)
23
+ >>> output_file = "/path/to/fixed.patch"
24
+ >>>
25
+ >>> with open(output_file, 'w', encoding='utf-8') as f:
26
+ ... f.writelines(fixed_lines)
27
+ >>>
28
+ ```
29
+ ### Command line:
30
+ ```bash
31
+ python patch_fixer/patch_fixer.py original broken.patch fixed.patch
32
+ ```
33
+ where `original` is the file or directory you were trying to patch,
34
+ `broken.patch` is the malformed patch generated by the LLM,
35
+ and `fixed.patch` is the output file containing the (hopefully) fixed patch.
36
+
37
+ ## Local Testing
38
+ ```bash
39
+ git clone https://github.com/ajcm474/patch-fixer.git
40
+ cd patch-fixer
41
+ pip install -e .[test]
42
+ pytest
43
+ ```
44
+ Note that some test failures are expected as this project is in the early alpha stage.
45
+ Please only report test failures if the same test passed in a previous version.
46
+
47
+ ## License
48
+
49
+ This is free and open source software, released under the Apache 2.0 License. See `LICENSE` for details.
@@ -162,7 +162,7 @@ def fix_patch(patch_lines, original):
162
162
  ) = capture_hunk(current_hunk, original_lines, offset, last_hunk, hunk_context)
163
163
  except MissingHunkError:
164
164
  raise NotImplementedError(f"Could not find hunk in {current_file}:"
165
- f"\n\n{"\n".join(current_hunk)}")
165
+ f"\n\n{"".join(current_hunk)}")
166
166
  fixed_lines.append(fixed_header)
167
167
  fixed_lines.extend(current_hunk)
168
168
  current_hunk = []
@@ -343,7 +343,7 @@ def fix_patch(patch_lines, original):
343
343
  ) = capture_hunk(current_hunk, original_lines, offset, last_hunk, hunk_context)
344
344
  except MissingHunkError:
345
345
  raise NotImplementedError(f"Could not find hunk in {current_file}:"
346
- f"\n\n{"\n".join(current_hunk)}")
346
+ f"\n\n{"".join(current_hunk)}")
347
347
  fixed_lines.append(fixed_header)
348
348
  fixed_lines.extend(current_hunk)
349
349
  current_hunk = []
@@ -365,7 +365,7 @@ def fix_patch(patch_lines, original):
365
365
  ) = capture_hunk(current_hunk, original_lines, offset, last_hunk, hunk_context)
366
366
  except MissingHunkError:
367
367
  raise NotImplementedError(f"Could not find hunk in {current_file}:"
368
- f"\n\n{"\n".join(current_hunk)}")
368
+ f"\n\n{"".join(current_hunk)}")
369
369
  fixed_lines.append(fixed_header)
370
370
  fixed_lines.extend(current_hunk)
371
371
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patch-fixer
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Fixes erroneous git apply patches to the best of its ability.
5
5
  Maintainer-email: Alex Mueller <amueller474@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -30,27 +30,47 @@ Dynamic: license-file
30
30
  So you asked an LLM to generate a code diff, tried to apply it with `git apply`, and got a bunch of malformed patch errors? Well fear no more, `patch_fixer.py` is here to save the day... more or less.
31
31
 
32
32
  ## Installation
33
- ```
34
- git clone https://github.com/ajcm474/patch-fixer.git
35
- cd patch-fixer
36
- pip install -e .
33
+ ```bash
34
+ # Make sure you're using at least python 3.10
35
+ python -m venv .venv/
36
+ source .venv/bin/activate
37
+ pip install patch-fixer
37
38
  ```
38
39
 
39
40
  ## Usage
41
+ ### API:
42
+ ```python
43
+ >>> from patch_fixer import fix_patch
44
+ >>>
45
+ >>> patch_file = "/path/to/broken.patch"
46
+ >>> original = "/path/to/original/state" # file or directory being patched
47
+ >>> with open(patch_file, encoding="utf-8") as f:
48
+ ... patch_lines = f.readlines()
49
+ ...
50
+ >>> fixed_lines = fix_patch(patch_lines, original)
51
+ >>> output_file = "/path/to/fixed.patch"
52
+ >>>
53
+ >>> with open(output_file, 'w', encoding='utf-8') as f:
54
+ ... f.writelines(fixed_lines)
55
+ >>>
40
56
  ```
41
- python patch_fixer.py original broken.patch fixed.patch
57
+ ### Command line:
58
+ ```bash
59
+ python patch_fixer/patch_fixer.py original broken.patch fixed.patch
42
60
  ```
43
61
  where `original` is the file or directory you were trying to patch,
44
62
  `broken.patch` is the malformed patch generated by the LLM,
45
63
  and `fixed.patch` is the output file containing the (hopefully) fixed patch.
46
64
 
47
- ## Testing
48
- Assuming you've already cloned the repo:
49
- ```
65
+ ## Local Testing
66
+ ```bash
67
+ git clone https://github.com/ajcm474/patch-fixer.git
68
+ cd patch-fixer
50
69
  pip install -e .[test]
51
70
  pytest
52
71
  ```
53
- Note that some tests currently fail as this project is in the early alpha stage.
72
+ Note that some test failures are expected as this project is in the early alpha stage.
73
+ Please only report test failures if the same test passed in a previous version.
54
74
 
55
75
  ## License
56
76
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "patch-fixer"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  description = "Fixes erroneous git apply patches to the best of its ability."
9
9
  maintainers = [
10
10
  {name = "Alex Mueller", email="amueller474@gmail.com"},
@@ -1,29 +0,0 @@
1
- # patch-fixer
2
- So you asked an LLM to generate a code diff, tried to apply it with `git apply`, and got a bunch of malformed patch errors? Well fear no more, `patch_fixer.py` is here to save the day... more or less.
3
-
4
- ## Installation
5
- ```
6
- git clone https://github.com/ajcm474/patch-fixer.git
7
- cd patch-fixer
8
- pip install -e .
9
- ```
10
-
11
- ## Usage
12
- ```
13
- python patch_fixer.py original broken.patch fixed.patch
14
- ```
15
- where `original` is the file or directory you were trying to patch,
16
- `broken.patch` is the malformed patch generated by the LLM,
17
- and `fixed.patch` is the output file containing the (hopefully) fixed patch.
18
-
19
- ## Testing
20
- Assuming you've already cloned the repo:
21
- ```
22
- pip install -e .[test]
23
- pytest
24
- ```
25
- Note that some tests currently fail as this project is in the early alpha stage.
26
-
27
- ## License
28
-
29
- This is free and open source software, released under the Apache 2.0 License. See `LICENSE` for details.
File without changes
File without changes