tagdiff 0.1.0__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.
tagdiff/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from .core import get_changelog
2
+
3
+ __all__ = ["get_changelog"]
tagdiff/cli.py ADDED
@@ -0,0 +1,46 @@
1
+ import argparse
2
+ import json
3
+ import sys
4
+
5
+ from tagdiff.core import get_changelog
6
+
7
+
8
+ def main():
9
+ parser = argparse.ArgumentParser(description="Compare GitHub release tags.")
10
+ parser.add_argument("repo", help="GitHub repo in owner/name format")
11
+ parser.add_argument("old_version", help="Starting tag")
12
+ parser.add_argument("new_version", help="Ending tag")
13
+ parser.add_argument("--structured", action="store_true", help="Extract structured changelog using AI")
14
+ parser.add_argument("--model", help="AI model to use (e.g. gpt-4o)")
15
+ parser.add_argument("--output", help="Save result to a JSON file")
16
+ parser.add_argument("--verbose", action="store_true", help="Show progress during execution")
17
+ args = parser.parse_args()
18
+
19
+ try:
20
+ result = get_changelog(
21
+ args.repo,
22
+ args.old_version,
23
+ args.new_version,
24
+ structured=args.structured,
25
+ model=args.model,
26
+ verbose=args.verbose
27
+ )
28
+ except ValueError as exc:
29
+ print(json.dumps({"error": str(exc)}))
30
+ return 1
31
+
32
+ formatted_result = json.dumps(result, indent=2)
33
+
34
+ if args.output:
35
+ with open(args.output, "w") as f:
36
+ f.write(formatted_result)
37
+ if args.verbose:
38
+ print(f"Result saved to {args.output}")
39
+ else:
40
+ print(formatted_result)
41
+
42
+ return 0
43
+
44
+
45
+ if __name__ == "__main__":
46
+ sys.exit(main())
tagdiff/core.py ADDED
@@ -0,0 +1,148 @@
1
+ import json
2
+ import os
3
+ import requests
4
+ from concurrent.futures import ThreadPoolExecutor
5
+
6
+ def fetch_releases(repo, stop_at_tag=None):
7
+ token = os.getenv("GITHUB_TOKEN")
8
+ headers = {}
9
+ if token:
10
+ headers["Authorization"] = f"token {token}"
11
+
12
+ releases = []
13
+ page = 1
14
+ while True:
15
+ url = f"https://api.github.com/repos/{repo}/releases?page={page}&per_page=100"
16
+ response = requests.get(url, headers=headers, timeout=30)
17
+ if response.status_code != 200:
18
+ if response.status_code == 403:
19
+ raise ValueError("GitHub API rate limit exceeded. Use GITHUB_TOKEN to increase limits.")
20
+ break
21
+
22
+ data = response.json()
23
+ if not data:
24
+ break
25
+
26
+ releases.extend(data)
27
+
28
+ # Check if we found the stop_at_tag
29
+ if stop_at_tag:
30
+ found = any(r.get("tag_name") == stop_at_tag for r in data)
31
+ if found:
32
+ break
33
+
34
+ page += 1
35
+ if page > 10: # Safety limit
36
+ break
37
+
38
+ return releases
39
+
40
+
41
+ def get_changes_between_versions(releases, old_version, new_version, structured=False, model=None, verbose=False):
42
+ changes = {}
43
+ ordered_releases = list(reversed(releases))
44
+
45
+ to_process = []
46
+ collecting = False
47
+ for release in ordered_releases:
48
+ tag = release.get("tag_name")
49
+ if tag == old_version:
50
+ collecting = True
51
+ continue
52
+
53
+ if tag == new_version:
54
+ break
55
+
56
+ if collecting:
57
+ to_process.append(release)
58
+
59
+ def process_release(release):
60
+ tag = release.get("tag_name")
61
+ published_at = release.get("published_at")
62
+ changelog = release.get("body")
63
+
64
+ if verbose:
65
+ print(f"Processing {tag}...")
66
+
67
+ change_data = {
68
+ "published_at": published_at,
69
+ "changelog": changelog,
70
+ }
71
+
72
+ if structured and changelog and changelog.strip():
73
+ structured_data = generate_structured_changelog(changelog, model=model)
74
+ if structured_data:
75
+ change_data["structured_changelog"] = structured_data
76
+
77
+ return tag, change_data
78
+
79
+ # Parallelize LLM calls
80
+ if structured and to_process:
81
+ with ThreadPoolExecutor(max_workers=5) as executor:
82
+ results = list(executor.map(process_release, to_process))
83
+ for tag, data in results:
84
+ changes[tag] = data
85
+ else:
86
+ for release in to_process:
87
+ tag, data = process_release(release)
88
+ changes[tag] = data
89
+
90
+ return changes
91
+
92
+
93
+ def get_changelog(repo, old_version, new_version, structured=False, model=None, verbose=False):
94
+ releases = fetch_releases(repo, stop_at_tag=old_version)
95
+ if not releases:
96
+ raise ValueError(f"Could not fetch releases for repo: {repo}")
97
+
98
+ changes = get_changes_between_versions(
99
+ releases,
100
+ old_version,
101
+ new_version,
102
+ structured=structured,
103
+ model=model,
104
+ verbose=verbose
105
+ )
106
+
107
+ return {
108
+ "repo": repo,
109
+ "from": old_version,
110
+ "to": new_version,
111
+ "changes": changes,
112
+ }
113
+
114
+
115
+ def generate_structured_changelog(changelog_text, model=None):
116
+ try:
117
+ from litellm import completion
118
+ except ImportError:
119
+ return {"error": "litellm package missing. Install it with 'pip install litellm'"}
120
+
121
+ prompt = """
122
+ You are a changelog assistant.
123
+ Extract the following from the changelog text:
124
+ - breaking_changes (list of strings)
125
+ - features (list of strings)
126
+ - fixes (list of strings)
127
+ - deprecations (list of strings)
128
+ - other (list of strings)
129
+
130
+ Return ONLY JSON. Do not use markdown blocks.
131
+ """
132
+
133
+ if not model:
134
+ model = os.getenv("TAGDIFF_MODEL", "gpt-4o-mini")
135
+
136
+ try:
137
+ response = completion(
138
+ model=model,
139
+ messages=[
140
+ {"role": "system", "content": prompt},
141
+ {"role": "user", "content": changelog_text}
142
+ ],
143
+ response_format={"type": "json_object"}
144
+ )
145
+ content = response.choices[0].message.content
146
+ return json.loads(content)
147
+ except Exception as e:
148
+ return {"error": str(e)}
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.4
2
+ Name: tagdiff
3
+ Version: 0.1.0
4
+ Summary: Compare GitHub release changelogs between tags
5
+ Author-email: ar9av <ar9avg@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 ar9av
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/ar9av/tagdiff
29
+ Project-URL: Bug Tracker, https://github.com/ar9av/tagdiff/issues
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: OS Independent
33
+ Requires-Python: >=3.9
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: requests>=2.31.0
37
+ Requires-Dist: litellm>=1.0.0
38
+ Dynamic: license-file
39
+
40
+ # TagDiff
41
+
42
+ TagDiff compares GitHub release notes between two version tags.
43
+
44
+ ## What It Does
45
+ - Fetches releases from GitHub for a repository
46
+ - Compares releases between `old_version` and `new_version`
47
+ - Returns a JSON changelog result
48
+ - Uses one shared core function for package, CLI, and Docker
49
+
50
+ ## Project Structure
51
+ - `tagdiff/core.py`: shared logic (`get_changelog`)
52
+ - `tagdiff/cli.py`: CLI wrapper
53
+ - `tagdiff/__init__.py`: package export
54
+ - `pyproject.toml`: package + CLI entrypoint config
55
+ - `Dockerfile`: Docker image setup
56
+ - `startup.txt`: quick start commands
57
+
58
+ ## Install
59
+ ```powershell
60
+ python -m pip install .
61
+ ```
62
+
63
+ ## Run (CLI)
64
+ ```powershell
65
+ tagdiff owner/repo old_version new_version
66
+ ```
67
+
68
+ Example:
69
+ ```powershell
70
+ tagdiff psf/requests v2.31.0 v2.32.0
71
+ ```
72
+
73
+ ## Run (Module)
74
+ ```powershell
75
+ python -m tagdiff.cli psf/requests v2.31.0 v2.32.0
76
+ ```
77
+
78
+ ## Run (Docker)
79
+ ```powershell
80
+ docker build -t tagdiff-local .
81
+ docker run --rm tagdiff-local psf/requests v2.31.0 v2.32.0
82
+ ```
83
+
84
+ ## Use Core Function Directly
85
+ ```python
86
+ from tagdiff import get_changelog
87
+
88
+ result = get_changelog("psf/requests", "v2.31.0", "v2.32.0")
89
+ print(result)
90
+ ```
@@ -0,0 +1,9 @@
1
+ tagdiff/__init__.py,sha256=QNTGJ0ooySGskoiFKVhlUgIypTmqLnHXyj2589Gw284,61
2
+ tagdiff/cli.py,sha256=GPxNTXooKr4dFjdeXVq9uU5EG7jgZ3BtWqTiheg3VEY,1428
3
+ tagdiff/core.py,sha256=aSTiZenUXQakcC3D5pQtEOk_tl_5Xurk3t43rTW_C6s,4285
4
+ tagdiff-0.1.0.dist-info/licenses/LICENSE,sha256=P2FV1z_xATK0LC3b72iVe6JDUySez_SqauaeiyOL5bE,1062
5
+ tagdiff-0.1.0.dist-info/METADATA,sha256=fV_RQ8AT1miEIhGO9kDzJ-CGN95_gZaKojjocO6AtxY,2951
6
+ tagdiff-0.1.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
7
+ tagdiff-0.1.0.dist-info/entry_points.txt,sha256=OsP2pz8DllOtipMbATYQV5GFodp4WqGbHvjKEE7ewqg,45
8
+ tagdiff-0.1.0.dist-info/top_level.txt,sha256=AgdPSp8nqVotdkXEE41dPdGT23d1SCwl_69zeR8XS7Y,8
9
+ tagdiff-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ tagdiff = tagdiff.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ar9av
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ tagdiff