Skip to content

Commit dc5d3a1

Browse files
committed
add checkdiff fn configs
1 parent 777e25a commit dc5d3a1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

check_diff/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,35 @@ pub fn build_rustfmt_from_src(binary_path: PathBuf) -> Result<RustfmtRunner, Che
227227
});
228228
}
229229

230+
// # Run rusfmt with the --check flag to see if a diff is produced.
231+
//
232+
// Parameters:
233+
// $1: Path to a rustfmt binary
234+
// $2: Output file path for the diff
235+
// $3: Any additional configuration options to pass to rustfmt
236+
//
237+
// Globals:
238+
// $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4
239+
pub fn create_diff(binary_path: PathBuf, output_path: &Path, config: Option<Vec<String>>) {
240+
let config_arg: String = match config {
241+
Some(configs) => {
242+
let mut result = String::new();
243+
result.push(',');
244+
for arg in configs.iter() {
245+
result.push_str(arg.as_str());
246+
result.push(',');
247+
}
248+
result.pop();
249+
result
250+
}
251+
None => String::new(),
252+
};
253+
let config = format!(
254+
"error_on_line_overflow=false,error_on_unformatted=false{}",
255+
config_arg.as_str()
256+
);
257+
}
258+
230259
// Compiles and produces two rustfmt binaries.
231260
// One for the current master, and another for the feature branch
232261
// Parameters:

0 commit comments

Comments
 (0)