Skip to content
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

Fix changelog check #118

Closed
wants to merge 23 commits into from
Closed
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
32 changes: 21 additions & 11 deletions devtools/check_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

* additions are reported in CHANGELOG.rst
"""
import os
from pathlib import Path

folder = Path(__file__).resolve().parents[1]
changelog = Path('docs', 'CHANGELOG.rst')
contributing = Path('docs', 'CONTRIBUTING.rst')
import git


class ChangelogError(Exception):
Expand All @@ -18,13 +17,24 @@ class ChangelogError(Exception):
pass


with open(Path(folder, changelog), 'r') as fin:
folder = Path(__file__).resolve().parents[1]
changelog = Path("docs", "CHANGELOG.rst")
contributing = Path("docs", "CONTRIBUTING.rst")

repo = git.Repo(folder)

if repo.active_branch.name == "main":
print("You are on the main branch. Nothing to check.")
exit(0)

with open(Path(folder, changelog), "r") as fin:
for line in fin:
if line.startswith('v'):
if line.startswith("v"):
raise ChangelogError(
'You have not updated the CHANGELOG file. '
f'Please add a summary of your additions to {str(changelog)!r} '
f'as described in {str(contributing)!r}.'
)
elif line.startswith('*'):
break
"You have not updated the CHANGELOG file. "
f"Please add a summary of your additions to {str(changelog)!r} "
f"as described in {str(contributing)!r}."
)
elif line.startswith("*"):
print("Changelog updated.")
exit(0)
1 change: 1 addition & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Changelog
=========

* Change handling of CHANGELOG checks

v0.1.30 (2024-04-03)
------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ skip_install = true
commands_pre = python {toxinidir}/devtools/clean_dist_check.py
commands =
python --version
python {toxinidir}/devtools/check_changelog.py
python -m build
twine check dist/*.whl
twine check dist/*.tar.gz
Expand All @@ -95,8 +94,10 @@ commands =
usedevelop = true
deps =
-r{toxinidir}/devtools/docs_requirements.txt
gitpython
commands =
sphinx-build {posargs:-E} -b html docs/rst dist/docs
python {toxinidir}/devtools/check_changelog.py

[testenv:safety]
deps = safety
Expand Down
Loading