Skip to content

Commit 4d905e1

Browse files
committed
REL: 0.4.0
## What's new ### New Features (ENH) - New `booklet` command to adjust offsets and lengths ([PR #77](#77)) - New `uncompress` command ([PR #75](#75)) - New `update-offsets` command to adjust offsets and lengths ([PR #15](#15)) - New `rm` command ([PR #59](#59)) - `metadata`: now also displaying CreationDate, Creator, Keywords & Subject ([PR #73](#73)) - Add warning for out-of-bounds page range in pdfly `cat` command ([PR #58](#58)) ### Bug Fixes (BUG) - `2-up` command, that only showed one page per sheet, on the left side, with blank space on the right ([PR #78](#78)) [Full Changelog](0.3.3...0.4.0)
1 parent f35cfa0 commit 4d905e1

File tree

4 files changed

+40
-21
lines changed

4 files changed

+40
-21
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CHANGELOG
22

3-
## Version 0.4.0, not released yet
3+
## Version 0.4.0, 2024-12-08
44

55
### New Features (ENH)
66
- New `booklet` command to adjust offsets and lengths ([PR #77](https://github.com/py-pdf/pdfly/pull/77))

make_release.py

+34-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Internal tool to update the changelog."""
1+
"""Internal tool to update the CHANGELOG."""
22

33
import json
44
import subprocess
@@ -9,6 +9,11 @@
99

1010
from rich.prompt import Prompt
1111

12+
GH_ORG = "py-pdf"
13+
GH_PROJECT = "pdfly"
14+
VERSION_FILE_PATH = "pdfly/_version.py"
15+
CHANGELOG_FILE_PATH = "CHANGELOG.md"
16+
1217

1318
@dataclass(frozen=True)
1419
class Change:
@@ -27,6 +32,7 @@ def main(changelog_path: str) -> None:
2732
2833
Args:
2934
changelog_path: The location of the CHANGELOG file
35+
3036
"""
3137
changelog = get_changelog(changelog_path)
3238
git_tag = get_most_recent_git_tag()
@@ -41,7 +47,7 @@ def main(changelog_path: str) -> None:
4147

4248
today = datetime.now(tz=timezone.utc)
4349
header = f"## Version {new_version}, {today:%Y-%m-%d}\n"
44-
url = f"https://github.com/py-pdf/pdfly/compare/{git_tag}...{new_version}"
50+
url = f"https://github.com/{GH_ORG}/{GH_PROJECT}/compare/{git_tag}...{new_version}"
4551
trailer = f"\n[Full Changelog]({url})\n\n"
4652
new_entry = header + changes + trailer
4753
print(new_entry)
@@ -61,9 +67,9 @@ def main(changelog_path: str) -> None:
6167
def print_instructions(new_version: str) -> None:
6268
"""Print release instructions."""
6369
print("=" * 80)
64-
print(f"☑ _version.py was adjusted to '{new_version}'")
65-
print("☑ CHANGELOG.md was adjusted")
66-
print("")
70+
print(f"☑ {VERSION_FILE_PATH} was adjusted to '{new_version}'")
71+
print(f"☑ {CHANGELOG_FILE_PATH} was adjusted")
72+
print()
6773
print("Now run:")
6874
print(" git commit -eF RELEASE_COMMIT_MSG.md")
6975
print(f" git tag -s {new_version} -eF RELEASE_TAG_MSG.md")
@@ -73,7 +79,7 @@ def print_instructions(new_version: str) -> None:
7379

7480
def adjust_version_py(version: str) -> None:
7581
"""Adjust the __version__ string."""
76-
with open("pdfly/_version.py", "w") as fp:
82+
with open(VERSION_FILE_PATH, "w") as fp:
7783
fp.write(f'__version__ = "{version}"\n')
7884

7985

@@ -93,8 +99,7 @@ def get_version_interactive(new_version: str, changes: str) -> str:
9399

94100
def is_semantic_version(version: str) -> bool:
95101
"""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 pdfly only and we don't make pre-releases
102+
# This doesn't cover the edge-cases like pre-releases
98103
if version.count(".") != 2:
99104
return False
100105
try:
@@ -147,6 +152,7 @@ def version_bump(git_tag: str) -> str:
147152
148153
Returns:
149154
The new version where the patch version is bumped.
155+
150156
"""
151157
# just assume a patch version change
152158
major, minor, patch = git_tag.split(".")
@@ -162,6 +168,7 @@ def get_changelog(changelog_path: str) -> str:
162168
163169
Returns:
164170
Data of the CHANGELOG
171+
165172
"""
166173
with open(changelog_path) as fh:
167174
changelog = fh.read()
@@ -175,6 +182,7 @@ def write_changelog(new_changelog: str, changelog_path: str) -> None:
175182
Args:
176183
new_changelog: Contents of the new CHANGELOG
177184
changelog_path: Path where the CHANGELOG file is
185+
178186
"""
179187
with open(changelog_path, "w") as fh:
180188
fh.write(new_changelog)
@@ -189,6 +197,7 @@ def get_formatted_changes(git_tag: str) -> Tuple[str, str]:
189197
190198
Returns:
191199
Changes done since git_tag
200+
192201
"""
193202
commits = get_git_commits_since_tag(git_tag)
194203

@@ -249,8 +258,11 @@ def get_formatted_changes(git_tag: str) -> Tuple[str, str]:
249258

250259
if grouped:
251260
output += "\n### Other\n"
261+
output_with_user += "\n### Other\n"
252262
for prefix in grouped:
253-
output += f"- {prefix}: {grouped[prefix]}\n"
263+
for commit_dict in grouped[prefix]:
264+
output += f"- {prefix}: {commit_dict['msg']}\n"
265+
output_with_user += f"- {prefix}: {commit_dict['msg']} by @{commit_dict['author']}\n"
254266

255267
return output, output_with_user
256268

@@ -261,6 +273,7 @@ def get_most_recent_git_tag() -> str:
261273
262274
Returns:
263275
Most recently created git tag.
276+
264277
"""
265278
git_tag = str(
266279
subprocess.check_output(
@@ -280,18 +293,18 @@ def get_author_mapping(line_count: int) -> Dict[str, str]:
280293
281294
Returns:
282295
A mapping of long commit hashes to author login handles.
296+
283297
"""
284298
per_page = min(line_count, 100)
285299
page = 1
286300
mapping: Dict[str, str] = {}
287301
for _ in range(0, line_count, per_page):
288-
with urllib.request.urlopen( # noqa: S310
289-
f"https://api.github.com/repos/py-pdf/pdfly/commits?per_page={per_page}&page={page}"
302+
with urllib.request.urlopen(
303+
f"https://api.github.com/repos/{GH_ORG}/{GH_PROJECT}/commits?per_page={per_page}&page={page}"
290304
) as response:
291305
commits = json.loads(response.read())
292306
page += 1
293307
for commit in commits:
294-
print(commit)
295308
if commit["author"]:
296309
gh_handle = commit["author"]["login"]
297310
else:
@@ -311,8 +324,9 @@ def get_git_commits_since_tag(git_tag: str) -> List[Change]:
311324
312325
Returns:
313326
List of all changes since git_tag.
327+
314328
"""
315-
commits = str(
329+
commits = (
316330
subprocess.check_output(
317331
[
318332
"git",
@@ -323,8 +337,10 @@ def get_git_commits_since_tag(git_tag: str) -> List[Change]:
323337
],
324338
stderr=subprocess.STDOUT,
325339
)
326-
).strip("'b\\n")
327-
lines = commits.split("\\n")
340+
.decode("UTF-8")
341+
.strip()
342+
)
343+
lines = commits.splitlines()
328344
authors = get_author_mapping(len(lines))
329345
return [parse_commit_line(line, authors) for line in lines if line != ""]
330346

@@ -341,13 +357,14 @@ def parse_commit_line(line: str, authors: Dict[str, str]) -> Change:
341357
342358
Raises:
343359
ValueError: The commit line is not well-structured
360+
344361
"""
345362
parts = line.split(":::")
346363
if len(parts) != 3:
347364
raise ValueError(f"Invalid commit line: '{line}'")
348365
commit_hash, rest, author = parts
349366
if ":" in rest:
350-
prefix, message = rest.split(":", 1)
367+
prefix, message = rest.split(": ", 1)
351368
else:
352369
prefix = ""
353370
message = rest
@@ -374,4 +391,4 @@ def parse_commit_line(line: str, authors: Dict[str, str]) -> Change:
374391

375392

376393
if __name__ == "__main__":
377-
main("CHANGELOG.md")
394+
main(CHANGELOG_FILE_PATH)

pdfly/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.3"
1+
__version__ = "0.4.0"

pyproject.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ known_third_party = ["pytest", "setuptools"]
6262

6363
[tool.ruff]
6464
line-length = 120
65+
66+
[tool.ruff.lint]
6567
select = ["ALL"]
6668
ignore = [
6769
"D404", # First word of the docstring should not be "This"
@@ -140,9 +142,9 @@ ignore = [
140142
"FA100", # Missing `from __future__ import annotations`, but uses `typing.Optional`
141143
]
142144

143-
[tool.ruff.mccabe]
145+
[tool.ruff.lint.mccabe]
144146
max-complexity = 20 # Recommended: 10
145147

146-
[tool.ruff.per-file-ignores]
148+
[tool.ruff.lint.per-file-ignores]
147149
"sample-files/*" = ["D100", "INP001", "FA102", "I001"]
148150
"make_release.py" = ["T201", "S603", "S607"]

0 commit comments

Comments
 (0)