Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025

Conversation

ZedThree
Copy link
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.
Copy link
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 label Mar 12, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

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
21 checks passed
@ZedThree ZedThree deleted the fix-last-tag-distance branch March 13, 2025 12:03
@ZedThree
Copy link
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants