File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff 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:
You can’t perform that action at this time.
0 commit comments