Skip to content

Commit 86149f5

Browse files
authored
Merge branch 'trunk' into fix-md-section-depth
2 parents 83d3eb6 + 322506d commit 86149f5

35 files changed

+427
-117
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
- uses: actions/checkout@v3
3636

37-
- uses: hynek/build-and-inspect-python-package@f51d0e79a34e62af977fcfe458b41fa8490e6e65
37+
- uses: hynek/build-and-inspect-python-package@b5076c307dc91924a82ad150cdd1533b444d3310 # v2.12.0
3838

3939
- name: Set up ${{ matrix.python.name }}
4040
uses: actions/setup-python@v4
@@ -49,7 +49,7 @@ jobs:
4949
- run: nox -e ${{ matrix.task.nox }}
5050

5151
- name: Publish
52-
uses: actions/upload-artifact@v3
52+
uses: actions/upload-artifact@v4
5353
with:
5454
name: dist
5555
path: dist/
@@ -84,7 +84,7 @@ jobs:
8484
- uses: actions/checkout@v3
8585

8686
- name: Download package files
87-
uses: actions/download-artifact@v3
87+
uses: actions/download-artifact@v4
8888
with:
8989
name: dist
9090
path: dist/
@@ -104,10 +104,11 @@ jobs:
104104
- run: nox --python ${{ matrix.python.action }} -e ${{ matrix.task.nox }} -- --use-wheel dist/*.whl
105105

106106
- name: Upload coverage data
107-
uses: actions/upload-artifact@v3
107+
uses: actions/upload-artifact@v4
108108
with:
109-
name: coverage-data
109+
name: coverage-data-${{ matrix.python.action }}
110110
path: .coverage.*
111+
include-hidden-files: true
111112
if-no-files-found: ignore
112113

113114

@@ -130,7 +131,7 @@ jobs:
130131
- uses: actions/checkout@v3
131132

132133
- name: Download package files
133-
uses: actions/download-artifact@v3
134+
uses: actions/download-artifact@v4
134135
with:
135136
name: dist
136137
path: dist/
@@ -177,7 +178,7 @@ jobs:
177178
fetch-depth: 0
178179

179180
- name: Download package files
180-
uses: actions/download-artifact@v3
181+
uses: actions/download-artifact@v4
181182
with:
182183
name: dist
183184
path: dist/
@@ -245,7 +246,7 @@ jobs:
245246
- uses: actions/checkout@v3
246247

247248
- name: Download package files
248-
uses: actions/download-artifact@v3
249+
uses: actions/download-artifact@v4
249250
with:
250251
name: dist
251252
path: dist/
@@ -282,9 +283,11 @@ jobs:
282283

283284
- run: python -Im pip install --upgrade coverage[toml]
284285

285-
- uses: actions/download-artifact@v3
286+
- uses: actions/download-artifact@v4
286287
with:
287-
name: coverage-data
288+
pattern: coverage-data-*
289+
merge-multiple: true
290+
path: .
288291

289292
- name: Combine coverage & fail if it's <100%.
290293
run: |
@@ -298,10 +301,11 @@ jobs:
298301
python -Im coverage report --fail-under=100
299302
300303
- name: Upload HTML report if check failed.
301-
uses: actions/upload-artifact@v3
304+
uses: actions/upload-artifact@v4
302305
with:
303306
name: html-report
304307
path: htmlcov
308+
include-hidden-files: true
305309
if: ${{ failure() }}
306310

307311
# This is a meta-job to simplify PR CI enforcement configuration in GitHub.

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ ci:
44

55
repos:
66
- repo: https://github.com/psf/black
7-
rev: 24.8.0
7+
rev: 25.1.0
88
hooks:
99
- id: black
1010

1111
- repo: https://github.com/asottile/pyupgrade
12-
rev: v3.17.0
12+
rev: v3.19.1
1313
hooks:
1414
- id: pyupgrade
1515
args: [--py38-plus]
1616

1717
- repo: https://github.com/PyCQA/isort
18-
rev: 5.13.2
18+
rev: 6.0.1
1919
hooks:
2020
- id: isort
2121
additional_dependencies: [toml]
2222

2323
- repo: https://github.com/PyCQA/flake8
24-
rev: 7.1.1
24+
rev: 7.1.2
2525
hooks:
2626
- id: flake8
2727

2828
- repo: https://github.com/pre-commit/pre-commit-hooks
29-
rev: v4.6.0
29+
rev: v5.0.0
3030
hooks:
3131
- id: trailing-whitespace
3232
- id: end-of-file-fixer
@@ -35,6 +35,6 @@ repos:
3535
- id: check-yaml
3636

3737
- repo: https://github.com/twisted/towncrier
38-
rev: 24.7.1
38+
rev: 24.8.0
3939
hooks:
4040
- id: towncrier-check

.readthedocs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: 2
33
sphinx:
44
# We want to fail as this is also our CI check for the docs.
55
fail_on_warning: True
6+
configuration: docs/conf.py
67

78
# We don't need PDF and epub for the docs.
89
formats: []

NEWS.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,43 @@ Release notes
55

66
.. towncrier release notes start
77
8+
Towncrier 24.8.0 (2024-08-23)
9+
=============================
10+
11+
No changes since the previous release candidate.
12+
13+
14+
Features
15+
--------
16+
17+
- Add ``.gitkeep`` as an ignored filename. (`#643 <https://github.com/twisted/towncrier/issues/643>`_)
18+
- Config `ignore` option now supports wildcard matching via `fnmatch <https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch>`_. (`#644 <https://github.com/twisted/towncrier/issues/644>`_)
19+
- Add a config for enforcing issue names using regex. (`#649 <https://github.com/twisted/towncrier/issues/649>`_)
20+
21+
22+
Bugfixes
23+
--------
24+
25+
- The template file is now ignored based only on the file name. (`#638 <https://github.com/twisted/towncrier/issues/638>`_)
26+
- Control of the header formatting is once again completely up to the user when they are writing markdown files (fixes a regression introduced in [#610](https://github.com/twisted/towncrier/pull/610)). (`#651 <https://github.com/twisted/towncrier/issues/651>`_)
27+
- Fixed an issue where `issue_template` failed recognizing the issue name of files with a non-category suffix (`.md`) (`#654 <https://github.com/twisted/towncrier/issues/654>`_)
28+
- Fixed a bug where orphan news fragments (e.g. +abc1234.feature) would fail when an `issue_pattern` is configured. Orphan news fragments are now excempt from `issue_pattern` checks. (`#655 <https://github.com/twisted/towncrier/issues/655>`_)
29+
30+
31+
Deprecations and Removals
32+
-------------------------
33+
34+
- Moved towncrier version definition from src/towncrier/_version.py to pyproject.toml
35+
36+
towncrier.__version__ was removed, after being deprecated in 23.6.0. (`#640 <https://github.com/twisted/towncrier/issues/640>`_)
37+
38+
39+
Misc
40+
----
41+
42+
- `#640 <https://github.com/twisted/towncrier/issues/640>`_, `#657 <https://github.com/twisted/towncrier/issues/657>`_
43+
44+
845
Towncrier 24.7.1 (2024-07-31)
946
=============================
1047

RELEASE.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ In ``pyproject.toml`` the version is set using a PEP440 compliant string:
2323

2424
version = "19.9.0rc1"
2525

26-
Run ``venv/bin/towncrier build --yes`` to generate the news release NEWS file.
26+
Use `towncrier` to generate the news release NEWS file, but first,
27+
make sure the new version is installed::
28+
29+
venv/bin/pip install -e .
30+
venv/bin/towncrier build --yes
31+
2732
Commit and push to the primary repository, not a fork.
2833
It is important to not use a fork so that pushed tags end up in the primary repository,
2934
server provided secrets for publishing to PyPI are available, and maybe more.

docs/cli.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,10 @@ By default, ``towncrier`` compares the current branch against ``origin/main`` (a
121121
Use ``REMOTE-BRANCH`` instead of ``origin/main``::
122122

123123
$ towncrier check --compare-with origin/trunk
124+
125+
.. option:: --staged
126+
127+
Include files that have been staged for commit when checking for news fragments::
128+
129+
$ towncrier check --staged
130+
$ towncrier check --staged --compare-with origin/trunk

docs/configuration.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ A minimal configuration for a Python project looks like this:
1717
.. code-block:: toml
1818
1919
# pyproject.toml
20-
21-
[tool.towncrier]
22-
package = "myproject"
20+
[project]
21+
name = "myproject"
2322
2423
A minimal configuration for a non-Python project looks like this:
2524

@@ -36,9 +35,9 @@ Top level keys
3635
``name``
3736
The name of your project.
3837

39-
For Python projects that provide a ``package`` key, if left empty then the name will be automatically determined.
38+
For Python projects that provide a ``package`` key, if left empty then the name will be automatically determined from the ``package`` key.
4039

41-
``""`` by default.
40+
Defaults to the key ``[project.name]`` in ``pyproject.toml`` (if present), otherwise defaults to the empty string ``""``.
4241

4342
``version``
4443
The version of your project.
@@ -167,6 +166,8 @@ Extra top level keys for Python projects
167166
Allows ``name`` and ``version`` to be automatically determined from the Python package.
168167
Changes the default ``directory`` to be a ``newsfragments`` directory within this package.
169168

169+
Defaults to the key ``[project.name]`` in ``pyproject.toml`` (if present), otherwise defaults to the empty string ``""``.
170+
170171
``package_dir``
171172
The folder your package lives.
172173

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def docs(session: nox.Session) -> None:
8989

9090
@nox.session
9191
def build(session: nox.Session) -> None:
92-
session.install("build", "twine")
92+
session.install("build", "twine", "pkginfo>=1.12.0")
9393

9494
# If no argument is passed, build builds an sdist and then a wheel from
9595
# that sdist.

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "towncrier"
99
# For RC - 23.11.0rc1 (release candidate starts at 1)
1010
# For final - 23.11.0
1111
# make sure to follow PEP440
12-
version = "24.7.2.dev0"
12+
version = "24.8.0.dev0"
1313
description = "Building newsfiles for your project."
1414
readme = "README.rst"
1515
license = "MIT"
@@ -63,7 +63,10 @@ Distribution = "https://pypi.org/project/towncrier"
6363
exclude = [
6464
"admin",
6565
"bin",
66-
"docs",
66+
".github",
67+
".git-blame-ignore-revs",
68+
".pre-commit-config.yaml",
69+
".pre-commit-hooks.yaml",
6770
".readthedocs.yaml",
6871
"src/towncrier/newsfragments",
6972
]

src/towncrier/_builder.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,29 @@ def render_issue(issue_format: str | None, issue: str) -> str:
328328
return issue_format.format(issue=issue)
329329

330330

331+
def append_newlines_if_trailing_code_block(text: str) -> str:
332+
"""
333+
Appends two newlines to a text string if it ends with a code block.
334+
335+
Used by `render_fragments` to avoid appending link to issue number into the code block.
336+
"""
337+
# Search for the existence of a code block at the end. We do this by searching for:
338+
# 1. start of code block: two ":", followed by two newlines
339+
# 2. any number of indented, or empty, lines (or the code block would end)
340+
# 3. one line of indented text w/o a trailing newline (because the string is stripped)
341+
# 4. end of the string.
342+
indented_text = r" [ \t]+[^\n]*"
343+
empty_or_indented_text_lines = f"(({indented_text})?\n)*"
344+
regex = r"::\n\n" + empty_or_indented_text_lines + indented_text + "$"
345+
if re.search(regex, text):
346+
# We insert one space, the default template inserts another, which results
347+
# in the correct indentation given default bullet indentation.
348+
# Non-default templates with different indentation will likely encounter issues
349+
# if they have trailing code blocks.
350+
return text + "\n\n "
351+
return text
352+
353+
331354
def render_fragments(
332355
template: str,
333356
issue_format: str | None,
@@ -381,6 +404,7 @@ def render_fragments(
381404
# for the template, after formatting each issue number
382405
categories = {}
383406
for text, issues in entries:
407+
text = append_newlines_if_trailing_code_block(text)
384408
rendered = [render_issue(issue_format, i) for i in issues]
385409
categories[text] = rendered
386410

0 commit comments

Comments
 (0)