ruff/crates/ruff_cli/src
Zanie Blue 860ffb9549
Add ruff version with long version display (#8034)
Adds a new `ruff version` sub-command which displays long version
information in the style of `cargo` and `rustc`. We include the number
of commits since the last release tag if its a development build, in the
style of Python's versioneer.

```
❯ ruff version
ruff 0.1.0+14 (947940e91 2023-10-18)
```

```
❯ ruff version --output-format json
{
  "version": "0.1.0",
  "commit_info": {
    "short_commit_hash": "947940e91",
    "commit_hash": "947940e91269f20f6b3f8f8c7c63f8e914680e80",
    "commit_date": "2023-10-18",
    "last_tag": "v0.1.0",
    "commits_since_last_tag": 14
  }
}%
```

```
❯ cargo version
cargo 1.72.1 (103a7ff2e 2023-08-15)
```
## Test plan

I've tested this manually locally, but want to at least add unit tests
for the message formatting. We'd also want to check the next release to
ensure the information is correct.

I checked build behavior with a detached head and branches.

## Future work

We could include rustc and cargo versions from the build, the current
Python version, and other diagnostic information for bug reports.

The `--version` and `-V` output is unchanged. However, we could update
it to display the long ruff version without the rust and cargo versions
(this is what cargo does). We'll need to be careful to ensure this does
not break downstream packages which parse our version string.

```
❯ ruff --version
ruff 0.1.0
```

The LSP should be updated to use `ruff version --output-format json`
instead of parsing `ruff --version`.
2023-10-20 14:07:41 -05:00
..
bin Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
commands Add ruff version with long version display (#8034) 2023-10-20 14:07:41 -05:00
snapshots Add ruff version with long version display (#8034) 2023-10-20 14:07:41 -05:00
args.rs Add ruff version with long version display (#8034) 2023-10-20 14:07:41 -05:00
cache.rs Update CLI to respect fix applicability (#7769) 2023-10-06 03:41:43 +00:00
diagnostics.rs Avoid failed assertion when showing fixes from stdin (#8029) 2023-10-17 21:50:39 -04:00
lib.rs Add ruff version with long version display (#8034) 2023-10-20 14:07:41 -05:00
panic.rs Disallow unreachable_pub (#4314) 2023-05-11 18:00:00 -04:00
printer.rs Avoid failed assertion when showing fixes from stdin (#8029) 2023-10-17 21:50:39 -04:00
resolve.rs Rename ConfigProcessor to ConfigurationTransformer (#7536) 2023-09-20 14:17:06 +00:00
stdin.rs Move stdin formatting to its own command file (#6981) 2023-08-29 16:06:10 +00:00
version.rs Add ruff version with long version display (#8034) 2023-10-20 14:07:41 -05:00