From e596d5ec9e6baaae2ef0a2454453cfe17aecca39 Mon Sep 17 00:00:00 2001 From: AarushiShah-db Date: Thu, 13 Aug 2026 17:36:25 +0000 Subject: [PATCH] Keep dynamic git versioning; fix base for git+ installs `uv tool install git+` builds from a checkout uv strips tags out of, so the version base fell back to 0.0.0 (`0.0.0+193.g`). Add a `release-base` fallback in the uv-dynamic-versioning format so git installs report the intended release as the base (`0.1.0+193.g`) while keeping the per-commit suffix. Tag-visible builds (local/CI) still derive the base from the git tag as before. Co-authored-by: Isaac --- pyproject.toml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f81b2855..a5d0173e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,10 +44,21 @@ source = "uv-dynamic-versioning" [tool.uv-dynamic-versioning] vcs = "git" -# On a tagged commit: plain tag (e.g. `0.1.0`). Between tags: append the commit -# count and short hash as a local segment (e.g. `0.1.0+14.g93986a8`) so a -# reported version points back to an exact commit for bug reports. -format-jinja = "{% if distance == 0 %}{{ base }}{% else %}{{ base }}+{{ distance }}.g{{ commit }}{% endif %}" +# `base` is the newest git tag when tags are visible (local checkouts, full CI +# clones): on the tag itself the version is the plain tag (e.g. `0.1.0`), and +# between tags it appends the commit count + short hash (`0.1.0+14.g93986a8`) so +# a reported version maps back to an exact commit. +# +# `uv tool install git+` is the exception: uv builds git installs from a +# checkout it strips tags out of, so `base` there falls back to dunamai's `0.0.0` +# default. `release-base` backfills the intended release version for that case, +# so git installs report e.g. `0.1.0+193.g7f40880` instead of `0.0.0+193...`. +# BUMP THIS when cutting a release (same time you create the `v` tag). +format-jinja = """ +{%- set release_base = '0.1.0' -%} +{%- set v = base if base != '0.0.0' else release_base -%} +{%- if distance == 0 %}{{ v }}{% else %}{{ v }}+{{ distance }}.g{{ commit }}{% endif -%} +""" # Used only when git metadata is unavailable at build time (e.g. building from a # source archive with no `.git`). The normal install paths clone the repo, so # this is a last-resort so builds degrade instead of hard-failing.