Skip to content

Commit 8f290b3

Browse files
authored
All hotfixes in one PR (#1)
All hotfixes in one PR
2 parents e49bf35 + 7057c3c commit 8f290b3

File tree

12 files changed

+380
-80
lines changed

12 files changed

+380
-80
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

doc/LICENSE renamed to LICENSE

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,34 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2020
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
THE SOFTWARE.
23+
24+
----
25+
26+
The MIT License (MIT)
27+
28+
Copyright (c) 2019 JFrog LTD
29+
30+
31+
32+
Permission is hereby granted, free of charge, to any person obtaining a copy
33+
of this software and associated documentation files (the "Software"), to deal
34+
in the Software without restriction, including without limitation the rights
35+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36+
copies of the Software, and to permit persons to whom the Software is
37+
furnished to do so, subject to the following conditions:
38+
39+
40+
41+
The above copyright notice and this permission notice shall be included in
42+
all copies or substantial portions of the Software.
43+
44+
45+
46+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
52+
THE SOFTWARE.
53+

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
Library to parse and apply unified diffs.
1+
[![PyPI](https://img.shields.io/pypi/v/patch-ng)](https://pypi.python.org/pypi/patch-ng)
22

3-
[![Build Status](https://img.shields.io/travis/techtonik/python-patch/master)](https://travis-ci.org/techtonik/python-patch/branches) [![PyPI](https://img.shields.io/pypi/v/patch)](https://pypi.python.org/pypi/patch)
3+
## Patch NG (New Generation)
4+
5+
#### Library to parse and apply unified diffs.
6+
7+
#### Why did we fork this project?
8+
9+
This project is a fork from the original [python-patch](https://github.com/techtonik/python-patch) project.
10+
11+
As any other project, bugs are common during the development process, the combination of issues + pull requests are
12+
able to keep the constant improvement of a project. However, both community and author need to be aligned. When users,
13+
developers, the community, needs a fix which are important for their projects, but there is no answer from the author,
14+
or the time for response is not enough, then the most plausible way is forking and continuing a parallel development.
15+
16+
That's way we forked the original and accepted most of PRs waiting for review since jun/2019 (5 months from now).
417

518
### Features
619

@@ -32,8 +45,8 @@ module without external dependencies.
3245
patch.py diff.patch
3346

3447
You can also run the .zip file.
35-
36-
python patch-1.16.zip diff.patch
48+
49+
python patch-1.17.zip diff.patch
3750

3851
### Installation
3952

@@ -42,13 +55,11 @@ and use it from here. This setup will always be repeatable. But if
4255
you need to add `patch` module as a dependency, make sure to use strict
4356
specifiers to avoid hitting an API break when version 2 is released:
4457

45-
pip install "patch==1.*"
58+
pip install "patch-ng"
4659

4760

4861
### Other stuff
4962

5063
* [CHANGES](doc/CHANGES.md)
51-
* [LICENSE](doc/LICENSE)
64+
* [LICENSE: MIT](LICENSE)
5265
* [CREDITS](doc/CREDITS)
53-
54-
* [test coverage](http://techtonik.github.io/python-patch/tests/coverage/)

example/example.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import os
2+
import logging
3+
from patch import fromfile, fromstring
4+
5+
class PatchLogHandler(logging.Handler):
6+
def __init__(self):
7+
logging.Handler.__init__(self, logging.DEBUG)
8+
9+
def emit(self, record):
10+
logstr = self.format(record)
11+
print logstr
12+
13+
patchlog = logging.getLogger("patch")
14+
patchlog.handlers = []
15+
patchlog.addHandler(PatchLogHandler())
16+
17+
patch = fromstring("""--- /dev/null
18+
+++ b/newfile
19+
@@ -0,0 +0,3 @@
20+
+New file1
21+
+New file2
22+
+New file3
23+
""")
24+
25+
patch.apply(root=os.getcwd(), strip=0)
26+
27+
28+
with open("newfile", "rb") as f:
29+
newfile = f.read()
30+
assert "New file1\nNew file2\nNew file3\n" == newfile
31+
32+
patch = fromstring("""--- a/newfile
33+
+++ /dev/null
34+
@@ -0,3 +0,0 @@
35+
-New file1
36+
-New file2
37+
-New file3
38+
""")
39+
40+
result = patch.apply(root=os.getcwd(), strip=0)
41+
42+
assert os.path.exists("newfile") is False

0 commit comments

Comments
 (0)