Skip to content

Commit c484226

Browse files
authored
chore: integrate changelog with backend pyproject.toml and just file (baserow#5195)
* chore: integrate changelog with backend pyproject.toml and just file * address copliot feedback * address feedback
1 parent 18a5fc1 commit c484226

13 files changed

Lines changed: 105 additions & 237 deletions

File tree

backend/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ dev = [
152152
"build",
153153
"rust-just>=1.46.0",
154154
]
155+
changelog = [
156+
"typer==0.24.1",
157+
]
155158

156159
[tool.hatch.metadata]
157160
allow-direct-references = true

backend/uv.lock

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

changelog/.flake8

Lines changed: 0 additions & 9 deletions
This file was deleted.

changelog/Makefile

Lines changed: 0 additions & 107 deletions
This file was deleted.

changelog/README.md

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,12 @@
22
This util allows you to generate changelog entries without causing merge conflicts.
33

44
## Getting started
5-
### Setup environment
6-
Go into the `changelog` folder and run the following commands
75

8-
#### Create virtual environment
9-
```shell
10-
python3 -m venv venv
11-
```
12-
13-
#### Activate environment
14-
```shell
15-
source venv/bin/activate
16-
```
17-
18-
#### Install dependencies
19-
```shell
20-
python3 -m pip install -r requirements.txt
21-
```
6+
All changelog commands run from the repo root via `just`:
227

238
### Add a new entry
249
```shell
25-
python3 ./src/changelog.py add
10+
just changelog add
2611
```
2712
The command will ask you for the required information to create a new changelog entry.
2813

@@ -33,7 +18,7 @@ your workflow.
3318

3419
### Make a release
3520
```shell
36-
python3 ./src/changelog.py release <name-of-the-release>
21+
just changelog release <name-of-the-release>
3722
```
3823

3924
The command will do the following:
@@ -46,7 +31,7 @@ After you made a release you can move the `changelog.md` file to the root of the
4631
## Additional commands
4732
### Purge
4833
```shell
49-
python3 ./src/changelog.py purge
34+
just changelog purge
5035
```
5136

5237
This command will delete:
@@ -58,7 +43,7 @@ Be careful when running `purge` since it will delete these files permanently!
5843

5944
### Generate
6045
```shell
61-
python3 ./src/changelog.py generate
46+
just changelog generate
6247
```
6348
This command will generate a new `changelog.md` file without making a new release.
6449

@@ -97,4 +82,4 @@ via the CLI.
9782
### What should I do if I need to make changes to an existing release?
9883
If you have generated a new release, and you notice afterwards that you meant to change
9984
one of the entries before making the release you can change the content of the changelog
100-
entry in the JSON file directly and then run `python3 ./src/changelog.py generate`
85+
entry in the JSON file directly and then run `just changelog generate`

changelog/entries/unreleased/bug/fix_reusable_password_reset_tokens.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"message": "Fix password reset tokens not being invalidated after use, allowing persistent account takeover. Tokens are now single-use, token expiry reduced to 1 hour, and a confirmation email is sent on every password change.",
44
"issue_origin": "github",
55
"issue_number": 5165,
6-
"domain": "backend",
6+
"domain": "core",
77
"bullet_points": [],
88
"created_at": "2026-04-10"
99
}

changelog/pytest.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

changelog/requirements.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

changelog/setup.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

changelog/src/handler.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
import glob
12
import json
23
import os
34
import shutil
4-
import glob
5+
import subprocess
56
from datetime import datetime, timezone
67
from json import JSONDecodeError
78
from pathlib import Path
9+
from shutil import which
810
from typing import Dict, List, Optional, Union
911

10-
from domains import domain_types
1112
from changelog_entry import changelog_entry_types
12-
from pygit2 import Repository
13+
from domains import domain_types
1314

1415
LINE_BREAK_CHARACTER = "\n"
1516
INDENT_CHARACTER = " "
@@ -250,11 +251,18 @@ def generate_entry_file_name(
250251

251252
@staticmethod
252253
def get_issue_number() -> Union[int, None]:
253-
potential_issue_number = Repository(".").head.shorthand.split("-")[0]
254-
255254
try:
256-
return int(potential_issue_number)
257-
except ValueError:
255+
git_path = which("git")
256+
if git_path is None:
257+
return None
258+
branch = subprocess.run( # noqa: S603
259+
[git_path, "rev-parse", "--abbrev-ref", "HEAD"],
260+
capture_output=True,
261+
text=True,
262+
check=True,
263+
).stdout.strip()
264+
return int(branch.split("-")[0])
265+
except (OSError, subprocess.CalledProcessError, ValueError):
258266
return None
259267

260268
def write_release_meta_data(self, name: str):

0 commit comments

Comments
 (0)