diff --git a/.ci/scripts/collect_changes.py b/.ci/scripts/collect_changes.py old mode 100644 new mode 100755 index f202c2282..f2c936f68 --- a/.ci/scripts/collect_changes.py +++ b/.ci/scripts/collect_changes.py @@ -1,3 +1,5 @@ +#!/bin/env python3 + import itertools import os import re diff --git a/cookiecutter/ci/{{ cookiecutter.__project_slug }}/.ci/scripts/collect_changes.py b/cookiecutter/ci/{{ cookiecutter.__project_slug }}/.ci/scripts/collect_changes.py index 3565db456..f2c936f68 100755 --- a/cookiecutter/ci/{{ cookiecutter.__project_slug }}/.ci/scripts/collect_changes.py +++ b/cookiecutter/ci/{{ cookiecutter.__project_slug }}/.ci/scripts/collect_changes.py @@ -1,3 +1,5 @@ +#!/bin/env python3 + import itertools import os import re @@ -21,8 +23,12 @@ TITLE_FORMAT = tc_settings.get("title_format", "{name} {version} ({project_date})") +# Build a regex to find the header of a changelog section. +# It must have a single capture group to single out the version. +# see help(re.split) for more info. NAME_REGEX = r".*" -VERSION_REGEX = r"([0-9]+\.[0-9]+\.[0-9][0-9ab]*)" +VERSION_REGEX = r"[0-9]+\.[0-9]+\.[0-9][0-9ab]*" +VERSION_CAPTURE_REGEX = rf"({VERSION_REGEX})" DATE_REGEX = r"[0-9]{4}-[0-9]{2}-[0-9]{2}" TITLE_REGEX = ( "(" @@ -30,6 +36,7 @@ TITLE_FORMAT.format(name="NAME_REGEX", version="VERSION_REGEX", project_date="DATE_REGEX") ) .replace("NAME_REGEX", NAME_REGEX) + .replace("VERSION_REGEX", VERSION_CAPTURE_REGEX, 1) .replace("VERSION_REGEX", VERSION_REGEX) .replace("DATE_REGEX", DATE_REGEX) + ")"