News fragments and changelogs#
repoplone writes every changelog of a repository from towncrier news fragments.
This page explains how fragments become changelogs, why a repository has several of them, and how repoplone changelog check decides where a fragment is missing.
Fragments instead of editing the changelog#
A news fragment is a small file that describes one change, such as news/91.bugfix.
Its name carries the issue number and the type of change.
Its content is the sentence that will appear in the changelog.
Writing a fragment per change avoids the conflicts that come from many branches editing the top of one CHANGELOG.md.
At release time, towncrier collects the fragments, writes them into the changelog under the new version, and removes them.
Plone and its add-ons have worked this way for years.
One changelog per package, one for the project#
Each package of a repository has its own news folder and its own changelog. Its towncrier configuration names both. A published package needs its own changelog, because that is what its users read on PyPI or npm.
The repository has a changelog too: the one the team reads to see what a release of the project brought.
repoplone builds it by gathering the changes of every package under one heading per package.
When [repository.towncrier] is set, the repository also gets its own news folder, for changes that belong to no package, such as CI, documentation, or deployment.
During a release, repoplone runs towncrier once per package and once for the repository, with the same version.
repoplone changelog preview shows the result without writing anything.
Areas#
repoplone changelog check sees a repository as a set of areas.
An area is a place with its own towncrier configuration: each package, and the repository itself when [repository.towncrier] is set.
Every changed file belongs to exactly one area: the most specific one whose folder holds it.
A file under packages/videos-core/ belongs to the videos-core package, even though the repository area holds it too.
The repository area gets every file that no package holds, such as the apps’ folders, the CI workflows, or the root README.md.
An area requires a fragment when one of its files changed. It has one when the change adds a file to its news folder that towncrier accepts as a fragment. Files inside a news folder never count as changes. A change that only adds fragments requires nothing.
Which changes count#
The check compares the current branch with the branch it started from.
It counts what the branch changed since it left that branch, the merge base, rather than every difference between the two.
A branch that is behind main does not pick up the changes main made since.
Uncommitted and untracked files count too. You can run the check before you commit, and get the same answer CI will give after you push. A moved file counts in both its old and its new area, because the change touches both.
Why not towncrier check#
towncrier ships a check command.
It answers one question: did the branch add a fragment to one news folder?
It does not know which packages a change touched.
Run once per package, it marks every package as needing a fragment as soon as anything in the repository changed.
repoplone knows the packages and their folders. It matches changed files to areas itself, and uses towncrier only to read each configuration and to parse fragment names.
See also
Add news fragments, to write a fragment.
Check news fragments in CI, to check fragments on every pull request.