Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ dev = [
"build",
"rust-just>=1.46.0",
]
changelog = [
"typer==0.24.1",
]

[tool.hatch.metadata]
allow-direct-references = true
Expand Down
37 changes: 37 additions & 0 deletions backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions changelog/.flake8

This file was deleted.

107 changes: 0 additions & 107 deletions changelog/Makefile

This file was deleted.

27 changes: 6 additions & 21 deletions changelog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,12 @@
This util allows you to generate changelog entries without causing merge conflicts.

## Getting started
### Setup environment
Go into the `changelog` folder and run the following commands

#### Create virtual environment
```shell
python3 -m venv venv
```

#### Activate environment
```shell
source venv/bin/activate
```

#### Install dependencies
```shell
python3 -m pip install -r requirements.txt
```
All changelog commands run from the repo root via `just`:

### Add a new entry
```shell
python3 ./src/changelog.py add
just changelog add
```
The command will ask you for the required information to create a new changelog entry.

Expand All @@ -33,7 +18,7 @@ your workflow.

### Make a release
```shell
python3 ./src/changelog.py release <name-of-the-release>
just changelog release <name-of-the-release>
```

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

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

### Generate
```shell
python3 ./src/changelog.py generate
just changelog generate
```
This command will generate a new `changelog.md` file without making a new release.

Expand Down Expand Up @@ -97,4 +82,4 @@ via the CLI.
### What should I do if I need to make changes to an existing release?
If you have generated a new release, and you notice afterwards that you meant to change
one of the entries before making the release you can change the content of the changelog
entry in the JSON file directly and then run `python3 ./src/changelog.py generate`
entry in the JSON file directly and then run `just changelog generate`
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"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.",
"issue_origin": "github",
"issue_number": 5165,
"domain": "backend",
"domain": "core",
"bullet_points": [],
"created_at": "2026-04-10"
}
2 changes: 0 additions & 2 deletions changelog/pytest.ini

This file was deleted.

8 changes: 0 additions & 8 deletions changelog/requirements.txt

This file was deleted.

18 changes: 0 additions & 18 deletions changelog/setup.py

This file was deleted.

22 changes: 15 additions & 7 deletions changelog/src/handler.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import glob
import json
import os
import shutil
import glob
import subprocess
from datetime import datetime, timezone
from json import JSONDecodeError
from pathlib import Path
from shutil import which
from typing import Dict, List, Optional, Union

from domains import domain_types
from changelog_entry import changelog_entry_types
from pygit2 import Repository
from domains import domain_types

LINE_BREAK_CHARACTER = "\n"
INDENT_CHARACTER = " "
Expand Down Expand Up @@ -250,11 +251,18 @@ def generate_entry_file_name(

@staticmethod
def get_issue_number() -> Union[int, None]:
potential_issue_number = Repository(".").head.shorthand.split("-")[0]

try:
return int(potential_issue_number)
except ValueError:
git_path = which("git")
if git_path is None:
return None
branch = subprocess.run( # noqa: S603
[git_path, "rev-parse", "--abbrev-ref", "HEAD"],
capture_output=True,
text=True,
check=True,
).stdout.strip()
return int(branch.split("-")[0])
except (OSError, subprocess.CalledProcessError, ValueError):
return None

def write_release_meta_data(self, name: str):
Expand Down
31 changes: 31 additions & 0 deletions changelog/tests/changelog/test_changelog_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
import subprocess
from unittest.mock import patch

from src.changelog_entry import BugChangelogEntry
from src.handler import MAXIMUM_FILE_NAME_MESSAGE_LENGTH, ChangelogHandler
Expand Down Expand Up @@ -162,3 +164,32 @@ def test_is_release_name_unique(fs):

assert ChangelogHandler().is_release_name_unique("exists") is False
assert ChangelogHandler().is_release_name_unique("not exists") is True


def test_get_issue_number_numeric_branch():
result = subprocess.CompletedProcess(args=[], returncode=0, stdout="123-my-feature\n")
with patch("src.handler.which", return_value="/usr/bin/git"), patch(
"src.handler.subprocess.run", return_value=result
):
assert ChangelogHandler.get_issue_number() == 123


def test_get_issue_number_non_numeric_branch():
result = subprocess.CompletedProcess(args=[], returncode=0, stdout="feature-branch\n")
with patch("src.handler.which", return_value="/usr/bin/git"), patch(
"src.handler.subprocess.run", return_value=result
):
assert ChangelogHandler.get_issue_number() is None


def test_get_issue_number_git_not_found():
with patch("src.handler.which", return_value=None):
assert ChangelogHandler.get_issue_number() is None


def test_get_issue_number_git_fails():
with patch("src.handler.which", return_value="/usr/bin/git"), patch(
"src.handler.subprocess.run",
side_effect=subprocess.CalledProcessError(128, "git"),
):
assert ChangelogHandler.get_issue_number() is None
Loading
Loading