Skip to content

Commit

Permalink
Merge pull request #4181 from schitcrafter/cli-locked-schema-ignore-l…
Browse files Browse the repository at this point in the history
…ineendings

Ignore newlines while comparing schemas
  • Loading branch information
weiznich authored Aug 23, 2024
2 parents 81c8f3c + 93f38e8 commit 83da2f0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions diesel_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,12 @@ fn regenerate_schema_if_file_specified(matches: &ArgMatches) -> Result<(), crate
}

if matches.get_flag("LOCKED_SCHEMA") {
let mut buf = Vec::new();
print_schema::run_print_schema(&mut connection, config, &mut buf)?;
let schema = print_schema::output_schema(&mut connection, config)?;

let old_buf = std::fs::read(path)
let old_buf = std::fs::read_to_string(path)
.map_err(|e| crate::errors::Error::IoError(e, Some(path.to_owned())))?;

if buf != old_buf {
if schema.lines().ne(old_buf.lines()) {
return Err(crate::errors::Error::SchemaWouldChange(
path.display().to_string(),
));
Expand Down

0 comments on commit 83da2f0

Please sign in to comment.