1
- """Internal tool to update the changelog ."""
1
+ """Internal tool to update the CHANGELOG ."""
2
2
3
3
import json
4
4
import subprocess
9
9
10
10
from rich .prompt import Prompt
11
11
12
+ GH_ORG = "py-pdf"
13
+ GH_PROJECT = "pypdf"
14
+ VERSION_FILE_PATH = "pypdf/_version.py"
15
+ CHANGELOG_FILE_PATH = "CHANGELOG.md"
16
+
12
17
13
18
@dataclass (frozen = True )
14
19
class Change :
@@ -41,7 +46,7 @@ def main(changelog_path: str) -> None:
41
46
42
47
today = datetime .now (tz = timezone .utc )
43
48
header = f"## Version { new_version } , { today :%Y-%m-%d} \n "
44
- url = f"https://github.com/py-pdf/pypdf /compare/{ git_tag } ...{ new_version } "
49
+ url = f"https://github.com/{ GH_ORG } / { GH_PROJECT } /compare/{ git_tag } ...{ new_version } "
45
50
trailer = f"\n [Full Changelog]({ url } )\n \n "
46
51
new_entry = header + changes + trailer
47
52
print (new_entry )
@@ -61,8 +66,8 @@ def main(changelog_path: str) -> None:
61
66
def print_instructions (new_version : str ) -> None :
62
67
"""Print release instructions."""
63
68
print ("=" * 80 )
64
- print (f"☑ _version.py was adjusted to '{ new_version } '" )
65
- print ("☑ CHANGELOG.md was adjusted" )
69
+ print (f"☑ { VERSION_FILE_PATH } was adjusted to '{ new_version } '" )
70
+ print (f "☑ { CHANGELOG_FILE_PATH } was adjusted" )
66
71
print ("" )
67
72
print ("Now run:" )
68
73
print (" git commit -eF RELEASE_COMMIT_MSG.md" )
@@ -73,7 +78,7 @@ def print_instructions(new_version: str) -> None:
73
78
74
79
def adjust_version_py (version : str ) -> None :
75
80
"""Adjust the __version__ string."""
76
- with open ("pypdf/_version.py" , "w" ) as fp :
81
+ with open (VERSION_FILE_PATH , "w" ) as fp :
77
82
fp .write (f'__version__ = "{ version } "\n ' )
78
83
79
84
@@ -93,8 +98,7 @@ def get_version_interactive(new_version: str, changes: str) -> str:
93
98
94
99
def is_semantic_version (version : str ) -> bool :
95
100
"""Check if the given version is a semantic version."""
96
- # It's not so important to cover the edge-cases like pre-releases
97
- # This is meant for pypdf only and we don't make pre-releases
101
+ # This doesn't cover the edge-cases like pre-releases
98
102
if version .count ("." ) != 2 :
99
103
return False
100
104
try :
@@ -284,7 +288,7 @@ def get_author_mapping(line_count: int) -> Dict[str, str]:
284
288
mapping : Dict [str , str ] = {}
285
289
for _ in range (0 , line_count , per_page ):
286
290
with urllib .request .urlopen ( # noqa: S310
287
- f"https://api.github.com/repos/py-pdf/pypdf /commits?per_page={ per_page } &page={ page } "
291
+ f"https://api.github.com/repos/{ GH_ORG } / { GH_PROJECT } /commits?per_page={ per_page } &page={ page } "
288
292
) as response :
289
293
commits = json .loads (response .read ())
290
294
page += 1
@@ -366,4 +370,4 @@ def parse_commit_line(line: str, authors: Dict[str, str]) -> Change:
366
370
367
371
368
372
if __name__ == "__main__" :
369
- main ("CHANGELOG.md" )
373
+ main (CHANGELOG_FILE_PATH )
0 commit comments