Skip to content

Commit

Permalink
add check_diff crate skeleton code
Browse files Browse the repository at this point in the history
  • Loading branch information
benluiwj authored and ytmimi committed Jun 4, 2024
1 parent bf7bb56 commit efb790a
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 0 deletions.
1 change: 1 addition & 0 deletions check_diff/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
237 changes: 237 additions & 0 deletions check_diff/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions check_diff/Cargo.toml
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"] }
25 changes: 25 additions & 0 deletions check_diff/src/main.rs
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
);
}
8 changes: 8 additions & 0 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
files.push(PathBuf::from("src/lib.rs"));

let (reports, count, fails) = check_files(files, &Some(PathBuf::from("rustfmt.toml")));
Expand Down

0 comments on commit efb790a

Please sign in to comment.