patch-fixer 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
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.
- patch_fixer/patch_fixer.py +33 -2
- {patch_fixer-0.3.0.dist-info → patch_fixer-0.3.1.dist-info}/METADATA +3 -2
- patch_fixer-0.3.1.dist-info/RECORD +7 -0
- patch_fixer-0.3.0.dist-info/RECORD +0 -7
- {patch_fixer-0.3.0.dist-info → patch_fixer-0.3.1.dist-info}/WHEEL +0 -0
- {patch_fixer-0.3.0.dist-info → patch_fixer-0.3.1.dist-info}/licenses/LICENSE +0 -0
- {patch_fixer-0.3.0.dist-info → patch_fixer-0.3.1.dist-info}/top_level.txt +0 -0
patch_fixer/patch_fixer.py
CHANGED
@@ -25,9 +25,40 @@ class MissingHunkError(Exception):
|
|
25
25
|
pass
|
26
26
|
|
27
27
|
|
28
|
+
class BadCarriageReturn(ValueError):
|
29
|
+
pass
|
30
|
+
|
31
|
+
|
28
32
|
def normalize_line(line):
|
29
|
-
|
30
|
-
|
33
|
+
"""Normalize line endings while preserving whitespace."""
|
34
|
+
if not isinstance(line, str):
|
35
|
+
raise TypeError(f"Cannot normalize non-string object {line}")
|
36
|
+
|
37
|
+
# edge case: empty string
|
38
|
+
if line == "":
|
39
|
+
return "\n"
|
40
|
+
|
41
|
+
# special malformed ending: ...\n\r
|
42
|
+
if line.endswith("\n\r"):
|
43
|
+
raise BadCarriageReturn(f"carriage return after line feed: {line}")
|
44
|
+
|
45
|
+
# handle CRLF and simple CR/LF endings
|
46
|
+
if line.endswith("\r\n"):
|
47
|
+
core = line[:-2]
|
48
|
+
elif line.endswith("\r"):
|
49
|
+
core = line[:-1]
|
50
|
+
elif line.endswith("\n"):
|
51
|
+
core = line[:-1]
|
52
|
+
else:
|
53
|
+
core = line
|
54
|
+
|
55
|
+
# check for interior CR/LF (anything before the final terminator)
|
56
|
+
if "\n" in core:
|
57
|
+
raise ValueError(f"line feed in middle of line: {line}")
|
58
|
+
if "\r" in core:
|
59
|
+
raise BadCarriageReturn(f"carriage return in middle of line: {line}")
|
60
|
+
|
61
|
+
return core + "\n"
|
31
62
|
|
32
63
|
|
33
64
|
def find_hunk_start(context_lines, original_lines):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: patch-fixer
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.1
|
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
|
@@ -22,6 +22,7 @@ Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
23
23
|
Requires-Dist: GitPython
|
24
24
|
Provides-Extra: test
|
25
|
+
Requires-Dist: hypothesis; extra == "test"
|
25
26
|
Requires-Dist: pytest; extra == "test"
|
26
27
|
Requires-Dist: requests; extra == "test"
|
27
28
|
Dynamic: license-file
|
@@ -71,7 +72,7 @@ pytest
|
|
71
72
|
```
|
72
73
|
From version `0.3.0` onward (at least until version `1.0`), some test failures are expected
|
73
74
|
in bugfix versions as I like to use test-driven development to build out new features.
|
74
|
-
Please only report test failures if the same test passed in the most recent `0.x.0` version.
|
75
|
+
Please only report test failures if the same test existed and passed in the most recent `0.x.0` version.
|
75
76
|
|
76
77
|
## License
|
77
78
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
patch_fixer/__init__.py,sha256=bSp2H7JW2kz1WrT0dqlg64kZpklKPp1FZlDhq2XJ2uU,34
|
2
|
+
patch_fixer/patch_fixer.py,sha256=1Ny2NwVL4qStbVCrv6QE3b_8oPsFkPomJDLoAGUqNvI,20587
|
3
|
+
patch_fixer-0.3.1.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
4
|
+
patch_fixer-0.3.1.dist-info/METADATA,sha256=iOhEx8d5WJV3X-mMu-0hAjQWXD-gBEPWKkiE-HnNyso,2828
|
5
|
+
patch_fixer-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
patch_fixer-0.3.1.dist-info/top_level.txt,sha256=yyp3KjFgExJsrFsS9ZBCnkhb05xg8hPYhB7ncdpTOv0,12
|
7
|
+
patch_fixer-0.3.1.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
patch_fixer/__init__.py,sha256=bSp2H7JW2kz1WrT0dqlg64kZpklKPp1FZlDhq2XJ2uU,34
|
2
|
-
patch_fixer/patch_fixer.py,sha256=GIXSlWWbHy9gvZ61mOyxZ9oSqyIeR1rTKJDQGdZ-IYc,19730
|
3
|
-
patch_fixer-0.3.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
4
|
-
patch_fixer-0.3.0.dist-info/METADATA,sha256=tR6BAvwh8PvNyKouq0p1CN0aEsasymao-_9hkZCglP0,2773
|
5
|
-
patch_fixer-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
patch_fixer-0.3.0.dist-info/top_level.txt,sha256=yyp3KjFgExJsrFsS9ZBCnkhb05xg8hPYhB7ncdpTOv0,12
|
7
|
-
patch_fixer-0.3.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|