Skip to content

[ruff] Fix last_tag/commits_since_last_tag for version command - #16686

Merged
MichaReiser merged 1 commit into
astral-sh:mainfrom
PlasmaFAIR:fix-last-tag-distance
Mar 13, 2025
Merged

MichaReiser merged 1 commit into
astral-sh:mainfrom
PlasmaFAIR:fix-last-tag-distance

Conversation

@ZedThree

Copy link
Copy Markdown
Contributor

Summary

Since Ruff changed to GitHub releases, tags are no longer annotated and git describe no longer picks them up. Instead, it's necessary to also search lightweight tags.

This changes fixes the version command to give more accurate last_tag/commits_since_last_tag information. This only affects development builds, as this information is not present in releases.

Test Plan

Testing is a little tricky because this information changes on every commit. Running manually on current main and my branch:

main:

# cargo run --bin ruff -- version --output-format=text
ruff 0.9.10+2547 (dd2313ab0 2025-03-12)

# cargo run --bin ruff -- version --output-format=json
{
  "version": "0.9.10",
  "commit_info": {
    "short_commit_hash": "dd2313ab0",
    "commit_hash": "dd2313ab0faea90abf66a75f1b5c388e728d9d0a",
    "commit_date": "2025-03-12",
    "last_tag": "v0.4.10",
    "commits_since_last_tag": 2547
  }
}

This PR:

# cargo run --bin ruff -- version --output-format=text
ruff 0.9.10+46 (11f39f616 2025-03-12)

# cargo run --bin ruff -- version --output-format=json
{
  "version": "0.9.10",
  "commit_info": {
    "short_commit_hash": "11f39f616",
    "commit_hash": "11f39f6166c3d7a521725b938a166659f64abb59",
    "commit_date": "2025-03-12",
    "last_tag": "0.9.10",
    "commits_since_last_tag": 46
  }
}

Since Ruff changed to GitHub releases, tags are no longer annotated
and `git describe` no longer picks them up.
@github-actions

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser
MichaReiser requested a review from zanieb March 12, 2025 17:49
@MichaReiser MichaReiser added the cli Related to the command-line interface of Ruff or ty label Mar 12, 2025

@MichaReiser MichaReiser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this is great! We may need the same fix in uv (@zanieb)

@MichaReiser
MichaReiser merged commit a90cf9d into astral-sh:main Mar 13, 2025
@ZedThree
ZedThree deleted the fix-last-tag-distance branch March 13, 2025 12:03
@ZedThree

Copy link
Copy Markdown
Contributor Author

Looks like it's already been fixed in uv: astral-sh/uv@94bec44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the command-line interface of Ruff or ty

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants