-
Notifications
You must be signed in to change notification settings - Fork 915
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
Rust rewrite check_diff (Skeleton) #6166
Merged
Merged
Changes from all commits
Commits
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
This file contains 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 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,9 @@ | ||
[package] | ||
name = "check_diff" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = { version = "4.4.2", features = ["derive"] } |
This file contains 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,25 @@ | ||
use clap::Parser; | ||
/// Inputs for the check_diff script | ||
#[derive(Parser)] | ||
struct CliInputs { | ||
/// Git url of a rustfmt fork to compare against the latest master rustfmt | ||
remote_repo_url: String, | ||
/// Name of the feature branch on the forked repo | ||
feature_branch: String, | ||
/// Optional commit hash from the feature branch | ||
#[arg(short, long)] | ||
commit_hash: Option<String>, | ||
/// Optional comma separated list of rustfmt config options to | ||
/// pass when running the feature branch | ||
#[arg(value_delimiter = ',', short, long, num_args = 1..)] | ||
rustfmt_config: Option<Vec<String>>, | ||
} | ||
|
||
fn main() { | ||
let args = CliInputs::parse(); | ||
println!( | ||
"remote_repo_url: {:?}, feature_branch: {:?}, | ||
optional_commit_hash: {:?}, optional_rustfmt_config: {:?}", | ||
args.remote_repo_url, args.feature_branch, args.commit_hash, args.rustfmt_config | ||
); | ||
} |
This file contains 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 |
---|---|---|
|
@@ -390,6 +390,14 @@ fn self_tests() { | |
path.push("main.rs"); | ||
files.push(path); | ||
} | ||
// for crates that need to be included but lies outside src | ||
let external_crates = vec!["check_diff"]; | ||
for external_crate in external_crates { | ||
let mut path = PathBuf::from(external_crate); | ||
path.push("src"); | ||
path.push("main.rs"); | ||
files.push(path); | ||
} | ||
Comment on lines
+394
to
+400
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wanted to note that if we add a |
||
files.push(PathBuf::from("src/lib.rs")); | ||
|
||
let (reports, count, fails) = check_files(files, &Some(PathBuf::from("rustfmt.toml"))); | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make sure to run rustfmt built from source on these files
cargo run --bin rustfmt -- check_diff/src/main.rs
I believe there are certain lines that exceed themax_width
.It would probably be worth adding the
check_diff
crate to rustfmt'sself_test
to ensure that these files stay formatted:rustfmt/src/test/mod.rs
Lines 382 to 411 in 871113e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some code here to deal with external crates instead of modifying the existing loop.