Skip to content

Fix .git_archival.txt version for tags like 2024-01-15 - #168

Merged
dolfinus merged 1 commit into
dolfinus:masterfrom
TohruSu:fix-archival-hyphenated-tag
Nov 11, 2026
Merged

dolfinus merged 1 commit into
dolfinus:masterfrom
TohruSu:fix-archival-hyphenated-tag

Conversation

@TohruSu

@TohruSu TohruSu commented Nov 11, 2026

Copy link
Copy Markdown

Change Summary

When the archived commit sits exactly on a tag, describe-name in .git_archival.txt is just the tag name. _parse_describe() does rsplit("-", 2) and assumes tag-N-gSHA as long as the middle piece is a number, so a date-style tag like 2024-01-15 comes out as tag 2024 with 1 commit on top.

With the default templates:

git checkout:            2024.1.15
extracted git archive:   2024.post1+git.<sha>

Now the suffix is only stripped when it really looks like -N-g<hex>; anything else is taken as the tag. Hyphenated tags with a real suffix (2024-01-15-3-g4060507) still parse the same way.

Side effect: a suffix without the leading g (v1.2.3-5-abc1234) is not split anymore. git describe always adds the g, so this shouldn't matter in practice.

I added a few unit cases and an end-to-end test that tags a commit 2024-01-15 and checks that the repo and the extracted archive give the same version.

I only ran this on Windows with Python 3.14. test_archival.py passes. 16 other tests (test_substitution_timestamp, *_git_missing, *_git_not_executable) fail there with or without this change.

Checklist

  • Commit message and PR title is comprehensive
  • Keep the change as small as possible
  • Unit and integration tests for the changes exist
  • Tests pass on CI and coverage does not decrease
  • Documentation reflects the changes where applicable
  • docs/changelog/next_release/<pull request or issue id>.<change type>.rst file added describing change
    (see CONTRIBUTING.rst for details.)
  • My PR is ready to review.

@TohruSu
TohruSu requested a review from dolfinus as a code owner November 11, 2026 03:10
@dolfinus

Copy link
Copy Markdown
Owner

Hi. Thank you for your contribution!

@dolfinus
dolfinus merged commit bf36548 into dolfinus:master Nov 11, 2026
8 of 9 checks passed
@TohruSu

TohruSu commented Nov 11, 2026

Copy link
Copy Markdown
Author

Hi. Thank you for your contribution!

Thank you for reviewing and merging this!

@TohruSu
TohruSu deleted the fix-archival-hyphenated-tag branch November 11, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants