uv
uv copied to clipboard
FRs: Commit lint and changelog generation
This issue is an extension of #6298 (version bumping) for related enhancements. Combining into one issue so as not to inundate the team (but can split into multiple issues if that is preferred).
Standards-compliant project management actions like auto-version bumping (SemVer), changelog generation (Keep a Changelog) and commit message linting (Conventional Commits) might be good tasks for the project management tool to tackle and promote best practices for development. It would consolidate the tooling even further, save time for the developer, and reduce the cognitive load. Defining the rules and formats in pyproject.toml could provide consistency and configurability for any codebase.
Example
pyproject.toml
[tool.uv.bump]
version-files = ["src/project/__init__.py:__version__"]
version-format = "semver2"
[tool.uv.commit]
lint-commits = true
commit-format = "conventional-commits"
[tool.uv.changelog]
generate-on-bump = true
include-date = true
date-format = "iso8601"
[tool.uv.changelog-map]
feat = "⭐ Features"
fix = "🐛 Bug Fixes"
chore = "🧹 Chores"
ci = "🚀 Continuous Integration"
docs = "📚 Documentation"
perf = "🔥 Performance Improvements"
refactor = "🔨 Refactoring"
revert = "🔄 Reverts"
style = "🎨 Styling"
test = "🧪 Tests"
Command line usage
Commiting via uv will lint the commit message for applicable conventional commit tags and reject if there isn’t one. This can just shell out to git detected on the path.
uv commit “fix: Always invoke found interpreter when `uv run python` is used (#6363)”
or
uv commit fix “Always invoke …”
Bumping will bump versions for all listed files or file sections (e.g. __version__.py or __init__.py:__version__). Not sure if there’s a consensus on the best place to put the version so version-files provides flexibility.
uv bump
Changelog generation can also be its own command if generate-on-bump is not desired.
uv changelog
Generated changelog
CHANGELOG.md
# Changelog
## 0.3.1 (2024-08-21)
### 🐛 Bug Fixes
- Always invoke found interpreter when `uv run python` is used ([#6363](https://github.com/astral-sh/uv/pull/6363))
### 📚 Documentation
- Remove the preview default value of `python-preference` ([#6301](https://github.com/astral-sh/uv/pull/6301))
- Update env vars doc about `XDG_*` variables on macOS ([#6337](https://github.com/astral-sh/uv/pull/6337))
See also: Commitizen, a tool that provides these capabilities.
This would be cool, of course. We use rooster right now, but it's not polished at all.
I think we need to focus on a lot of other things before this though.
By the way, there is git-cliff, and it works for any projects, not just python ones.
https://github.com/astral-sh/uv/issues/6298#issuecomment-2350938745
Using uvx hatch version ... is mostly fine, but I can't use it when it's a stub only package because there is no *.py.
I need a way to work around this case. It would be great if this was considered. As someone else pointed out, it can be solved by doing the following, but it's ugly. https://github.com/astral-sh/uv/issues/6298#issuecomment-2411738585
As a workaround, I use this in my project:
sed -i -e "s/0.0.0/${GITHUB_REF#refs/*/}/" pyproject.toml
I too would love this!