astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
31.85k stars 1.07k forks source link

Add info about used git commit into `ruff --version` if available #11691

Open qarmin opened 4 months ago

qarmin commented 4 months ago

Currently git version of app, always for ruff --version prints something like

ruff 0.4.7

I think that here could be added more info like

e.g.

ruff 0.4.7, abcdef, custom build
ruff 0.4.7, abcdef, from debian repository
ruff 0.4.7, abcdef, official package
MichaReiser commented 4 months ago

Uff, that took me a while to figure out myself. You can use ruff version to get the commit number (doesn't work for local builds).

zanieb commented 4 months ago

Yeah we added this in https://github.com/astral-sh/ruff/pull/8034

As mentioned there, we could include this for the -V / --version flag. We didn't change it initially to avoid a breaking change for tools that parse the output. I think we should change this to match the uv behavior which is as follows:

❯ uv -V
uv 0.2.3
❯ uv --version
uv 0.2.3 (ce4d862b0 2024-05-24)
❯ uv version
uv 0.2.3 (ce4d862b0 2024-05-24)
KangOl commented 4 months ago

I would instead follow the same behavior as python which output the build info when --version (or -V) is provided twice. https://docs.python.org/3/using/cmdline.html#cmdoption-version

❯ python3 --version
Python 3.11.7
❯ python3 --version --version
Python 3.11.7 (main, Dec 18 2023, 10:50:03) [Clang 15.0.0 (clang-1500.1.0.2.5)]