summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-26 15:07:31 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-29 18:17:19 +0200
commitf3aaac38547e0dd9e1942a647e603465cf09ecff (patch)
treebcf5973b97eb4843aa1ad10c76d351f3671b1524 /script
parent86837c350450e0da64260c8e206c2cf6f882fb11 (diff)
downloadastroid-git-f3aaac38547e0dd9e1942a647e603465cf09ecff.tar.gz
Add logging in the bump version script
Diffstat (limited to 'script')
-rw-r--r--script/bump_changelog.py23
-rw-r--r--script/test_bump_changelog.py9
2 files changed, 26 insertions, 6 deletions
diff --git a/script/bump_changelog.py b/script/bump_changelog.py
index 23788002..4478b169 100644
--- a/script/bump_changelog.py
+++ b/script/bump_changelog.py
@@ -1,8 +1,10 @@
"""
This script permits to upgrade the changelog in astroid or pylint when releasing a version.
"""
+# pylint: disable=logging-fstring-interpolation
import argparse
import enum
+import logging
from datetime import datetime
from pathlib import Path
@@ -23,7 +25,13 @@ NEW_RELEASE_DATE_MESSAGE = "Release Date: {}".format(TODAY.strftime("%Y-%m-%d"))
def main() -> None:
parser = argparse.ArgumentParser(add_help=__doc__)
parser.add_argument("version", help="The version we want to release")
+ parser.add_argument(
+ "-v", "--verbose", action="store_true", default=False, help="Logging or not"
+ )
args = parser.parse_args()
+ if args.verbose:
+ logging.basicConfig(level=logging.DEBUG)
+ logging.debug(f"Launching bump_changelog with args: {args}")
if "dev" in args.version:
return
with open(DEFAULT_CHANGELOG_PATH) as f:
@@ -83,13 +91,20 @@ def transform_content(content: str, version: str) -> str:
version=next_version
)
index = content.find(WHATS_NEW_TEXT)
+ logging.debug(f"Replacing '{RELEASE_DATE_TEXT}' by '{NEW_RELEASE_DATE_MESSAGE}'")
content = content.replace(RELEASE_DATE_TEXT, NEW_RELEASE_DATE_MESSAGE)
end_content = content[index:]
content = content[:index]
- content += wn_next_version + "\n"
- content += "=" * len(wn_next_version) + "\n"
- content += RELEASE_DATE_TEXT + "\n" * 4
- content += end_content
+ to_add = (
+ wn_next_version
+ + "\n"
+ + "=" * len(wn_next_version)
+ + "\n"
+ + RELEASE_DATE_TEXT
+ + "\n" * 4
+ )
+ logging.debug(f"Adding:'{to_add}'")
+ content += to_add + end_content
return content
diff --git a/script/test_bump_changelog.py b/script/test_bump_changelog.py
index fcdbd225..cfb27e42 100644
--- a/script/test_bump_changelog.py
+++ b/script/test_bump_changelog.py
@@ -1,3 +1,5 @@
+import logging
+
import pytest
from bump_changelog import VersionType, get_next_version, transform_content
@@ -101,7 +103,8 @@ def test_update_content_error(old_content, version, expected_error):
transform_content(old_content, version)
-def test_update_content():
+def test_update_content(caplog):
+ caplog.set_level(logging.DEBUG)
old_content = """
===================
astroid's ChangeLog
@@ -127,4 +130,6 @@ What's New in astroid 2.6.1?
Release Date: 20"""
new_content = transform_content(old_content, "2.6.1")
- assert new_content.startswith(expected_beginning)
+ assert new_content.startswith(
+ expected_beginning
+ ), f"Wrong start for:'{new_content[len(expected_beginning):]}'"