gptdiff 0.1.11__tar.gz → 0.1.13__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {gptdiff-0.1.11 → gptdiff-0.1.13}/PKG-INFO +1 -1
- gptdiff-0.1.13/gptdiff/gptdiffapply.py +63 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/gptdiff.egg-info/PKG-INFO +1 -1
- {gptdiff-0.1.11 → gptdiff-0.1.13}/gptdiff.egg-info/SOURCES.txt +1 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/gptdiff.egg-info/entry_points.txt +1 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/setup.py +5 -2
- {gptdiff-0.1.11 → gptdiff-0.1.13}/LICENSE.txt +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/README.md +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/gptdiff/__init__.py +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/gptdiff/gptdiff.py +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/gptdiff.egg-info/dependency_links.txt +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/gptdiff.egg-info/requires.txt +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/gptdiff.egg-info/top_level.txt +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/setup.cfg +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/tests/test_applydiff.py +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/tests/test_applydiff_edgecases.py +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/tests/test_diff_parse.py +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/tests/test_parse_diff_per_file.py +0 -0
- {gptdiff-0.1.11 → gptdiff-0.1.13}/tests/test_smartapply.py +0 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
Command line tool to apply a unified diff directly to a file system.
|
4
|
+
|
5
|
+
Usage:
|
6
|
+
gptapply --diff "<diff text>"
|
7
|
+
or
|
8
|
+
gptapply path/to/diff.patch
|
9
|
+
|
10
|
+
This tool uses the same patch-application logic as gptdiff.
|
11
|
+
"""
|
12
|
+
|
13
|
+
import sys
|
14
|
+
import argparse
|
15
|
+
from pathlib import Path
|
16
|
+
from gptdiff.gptdiff import apply_diff
|
17
|
+
|
18
|
+
|
19
|
+
def parse_arguments():
|
20
|
+
parser = argparse.ArgumentParser(
|
21
|
+
description="Apply a unified diff to the file system using GPTDiff's patch logic."
|
22
|
+
)
|
23
|
+
group = parser.add_mutually_exclusive_group(required=True)
|
24
|
+
group.add_argument(
|
25
|
+
"--diff",
|
26
|
+
type=str,
|
27
|
+
help="Unified diff text to apply (provide as a string)."
|
28
|
+
)
|
29
|
+
group.add_argument(
|
30
|
+
"diff_file",
|
31
|
+
nargs="?",
|
32
|
+
help="Path to a file containing the unified diff."
|
33
|
+
)
|
34
|
+
parser.add_argument(
|
35
|
+
"--project-dir",
|
36
|
+
type=str,
|
37
|
+
default=".",
|
38
|
+
help="Project directory where the diff should be applied (default: current directory)."
|
39
|
+
)
|
40
|
+
return parser.parse_args()
|
41
|
+
|
42
|
+
|
43
|
+
def main():
|
44
|
+
args = parse_arguments()
|
45
|
+
if args.diff:
|
46
|
+
diff_text = args.diff
|
47
|
+
else:
|
48
|
+
diff_path = Path(args.diff_file)
|
49
|
+
if not diff_path.exists():
|
50
|
+
print(f"Error: Diff file '{args.diff_file}' does not exist.")
|
51
|
+
sys.exit(1)
|
52
|
+
diff_text = diff_path.read_text(encoding="utf8")
|
53
|
+
|
54
|
+
project_dir = args.project_dir
|
55
|
+
success = apply_diff(project_dir, diff_text)
|
56
|
+
if success:
|
57
|
+
print("✅ Diff applied successfully.")
|
58
|
+
else:
|
59
|
+
print("❌ Failed to apply diff.")
|
60
|
+
|
61
|
+
|
62
|
+
if __name__ == "__main__":
|
63
|
+
main()
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='gptdiff',
|
5
|
-
version='0.1.
|
5
|
+
version='0.1.13',
|
6
6
|
description='A tool to generate and apply git diffs using LLMs',
|
7
7
|
author='255labs',
|
8
8
|
packages=find_packages(), # Use find_packages() to automatically discover packages
|
@@ -19,7 +19,10 @@ setup(
|
|
19
19
|
'docs': ['mkdocs', 'mkdocs-material']
|
20
20
|
},
|
21
21
|
entry_points={
|
22
|
-
'console_scripts': [
|
22
|
+
'console_scripts': [
|
23
|
+
'gptdiff=gptdiff.gptdiff:main',
|
24
|
+
'gptapply=gptdiff.gptdiffapply:main',
|
25
|
+
],
|
23
26
|
},
|
24
27
|
license=None, # Remove license argument
|
25
28
|
# license_file='LICENSE.txt', # Remove license_file argument
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|