-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add ruff version with long version display
#8034
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
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9853a22
Add `ruff version` with long version display
zanieb 0b1b490
Drop `shadow-rs` in favor of a way cooler hand-coded implementation
zanieb fb690af
Move "version" to bottom of commands
zanieb 25c071f
Remove `ruff_version`
zanieb 5e0f016
Lint
zanieb 2d1a199
Oops; commit version file
zanieb 355aba9
Remove unncessary `build.rs` specifier
zanieb 1208df9
Use git references to trigger rebuilds
zanieb 53b0f5d
Improve comments
zanieb 944b3e4
Add snapshots for version formatting
zanieb f8655ea
Handle edge cases when describe fails; add serialization test; lint
zanieb 996ddf1
Add ruff prefix
zanieb d685384
Commit snapshot
zanieb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| use std::process::Command; | ||
|
|
||
| fn main() { | ||
| commit_info(); | ||
| #[allow(clippy::disallowed_methods)] | ||
| let target = std::env::var("TARGET").unwrap(); | ||
| println!("cargo:rustc-env=RUST_HOST_TARGET={target}"); | ||
| } | ||
|
|
||
| fn commit_info() { | ||
| let output = match Command::new("git") | ||
| .arg("log") | ||
| .arg("-1") | ||
| .arg("--date=short") | ||
| .arg("--abbrev=9") | ||
| .arg("--format=%H %h %cd %(describe)") | ||
| .output() | ||
| { | ||
| Ok(output) if output.status.success() => output, | ||
| foo => foo.unwrap(), | ||
| }; | ||
| let stdout = String::from_utf8(output.stdout).unwrap(); | ||
| let mut parts = stdout.split_whitespace(); | ||
| let mut next = || parts.next().unwrap(); | ||
| println!("cargo:rustc-env=RUFF_COMMIT_HASH={}", next()); | ||
| println!("cargo:rustc-env=RUFF_COMMIT_SHORT_HASH={}", next()); | ||
| println!("cargo:rustc-env=RUFF_COMMIT_DATE={}", next()); | ||
|
|
||
| // Describe can fail for some commits | ||
| // https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-emdescribeoptionsem | ||
| if let Some(describe) = parts.next() { | ||
| let mut describe_parts = describe.split('-'); | ||
| println!( | ||
| "cargo:rustc-env=RUFF_LAST_TAG={}", | ||
| describe_parts.next().unwrap() | ||
| ); | ||
| // If this is the tagged commit, this component will be missing | ||
| println!( | ||
| "cargo:rustc-env=RUFF_LAST_TAG_DISTANCE={}", | ||
| describe_parts.next().unwrap_or("0") | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| use std::io::{self, BufWriter, Write}; | ||
|
|
||
| use anyhow::Result; | ||
|
|
||
| use crate::args::HelpFormat; | ||
|
|
||
| /// Display version information | ||
| pub(crate) fn version(output_format: HelpFormat) -> Result<()> { | ||
| let mut stdout = BufWriter::new(io::stdout().lock()); | ||
| let version_info = crate::version::version(); | ||
|
|
||
| match output_format { | ||
| HelpFormat::Text => { | ||
| writeln!(stdout, "{}", &version_info)?; | ||
| } | ||
| HelpFormat::Json => { | ||
| serde_json::to_writer_pretty(stdout, &version_info)?; | ||
| } | ||
| }; | ||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.