Skip to content

All hotfixes in one PR #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
31 changes: 31 additions & 0 deletions doc/LICENSE → LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,34 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

----

The MIT License (MIT)

Copyright (c) 2019 JFrog LTD



Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:



The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.



THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

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

[![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)
## Patch NG (New Generation)

#### Library to parse and apply unified diffs.

#### Why did we fork this project?

This project is a fork from the original [python-patch](https://github.com/techtonik/python-patch) project.

As any other project, bugs are common during the development process, the combination of issues + pull requests are
able to keep the constant improvement of a project. However, both community and author need to be aligned. When users,
developers, the community, needs a fix which are important for their projects, but there is no answer from the author,
or the time for response is not enough, then the most plausible way is forking and continuing a parallel development.

That's way we forked the original and accepted most of PRs waiting for review since jun/2019 (5 months from now).

### Features

Expand Down Expand Up @@ -32,8 +45,8 @@ module without external dependencies.
patch.py diff.patch

You can also run the .zip file.
python patch-1.16.zip diff.patch

python patch-1.17.zip diff.patch

### Installation

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

pip install "patch==1.*"
pip install "patch-ng"


### Other stuff

* [CHANGES](doc/CHANGES.md)
* [LICENSE](doc/LICENSE)
* [LICENSE: MIT](LICENSE)
* [CREDITS](doc/CREDITS)

* [test coverage](http://techtonik.github.io/python-patch/tests/coverage/)
42 changes: 42 additions & 0 deletions example/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import logging
from patch import fromfile, fromstring

class PatchLogHandler(logging.Handler):
def __init__(self):
logging.Handler.__init__(self, logging.DEBUG)

def emit(self, record):
logstr = self.format(record)
print logstr

patchlog = logging.getLogger("patch")
patchlog.handlers = []
patchlog.addHandler(PatchLogHandler())

patch = fromstring("""--- /dev/null
+++ b/newfile
@@ -0,0 +0,3 @@
+New file1
+New file2
+New file3
""")

patch.apply(root=os.getcwd(), strip=0)


with open("newfile", "rb") as f:
newfile = f.read()
assert "New file1\nNew file2\nNew file3\n" == newfile

patch = fromstring("""--- a/newfile
+++ /dev/null
@@ -0,3 +0,0 @@
-New file1
-New file2
-New file3
""")

result = patch.apply(root=os.getcwd(), strip=0)

assert os.path.exists("newfile") is False
Loading