diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 781f6a1..e4625f5 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -16,6 +16,7 @@ on: permissions: contents: read + checks: write jobs: audit: diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5db92..99bb77b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] +## [0.2.2] - 2026-10-24 + +### Fixed + +- Update ctutils to 0.4.4 and Tokio to 1.53.3 for RustSec fixes. +- Honor the configured CI report format and explicit CLI color mode. +- Enable CI exit codes in safe-migrate while preserving plan-only behavior. +- Keep database credentials out of command hints. +- Reject simultaneous TARGET and --schema inputs. +- Create config files atomically without overwriting existing paths or following dangling symlinks. + ## [0.2.0] - 2026-04-06 ### Added diff --git a/Cargo.lock b/Cargo.lock index cd7e9bf..77a049f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -376,9 +376,9 @@ dependencies = [ [[package]] name = "ctutils" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e" +checksum = "12218662ccac37d9714f2191252553d67585b97df8c839cbe49e0bde278dc865" dependencies = [ "cmov", ] @@ -419,7 +419,7 @@ dependencies = [ [[package]] name = "dbdiff" -version = "0.2.1" +version = "0.2.2" dependencies = [ "assert_cmd", "clap", @@ -1876,9 +1876,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.52.3" +version = "1.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e" dependencies = [ "bytes", "libc", diff --git a/Cargo.toml b/Cargo.toml index a3ecb7a..df1638d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dbdiff" -version = "0.2.1" +version = "0.2.2" edition = "2021" rust-version = "1.88" authors = ["rekurt"] diff --git a/README.md b/README.md index fde6c91..fa054d3 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ jobs: - uses: actions/checkout@v6 - uses: dtolnay/rust-toolchain@stable - name: Install dbdiff - run: cargo install --git https://github.com/rekurt/dbdiff --tag v0.2.1 --locked + run: cargo install --git https://github.com/rekurt/dbdiff --tag v0.2.2 --locked - name: Compare schemas run: dbdiff current.sql desired.sql --ci --format json > drift-report.json - name: Upload report diff --git a/doc/cli.md b/doc/cli.md index deafd5c..ffc83f5 100644 --- a/doc/cli.md +++ b/doc/cli.md @@ -75,7 +75,7 @@ dbdiff current.sql desired.sql --config custom.yml `dbdiff init` creates `.dbdiff.yml` only if the path does not exist. Existing files and symbolic links, including dangling links, are never overwritten. -By default, dbdiff reads `.dbdiff.yml` in the working directory. A missing file uses defaults. A present but invalid file returns an error. CLI format options override configured output format. +By default, dbdiff reads `.dbdiff.yml` in the working directory. A missing file uses defaults. A present but invalid file returns an error. CLI format options override configured output format, including `output.format: ci`. Explicit `--color always` and `--color never` override the config; `auto` keeps terminal detection and honors `output.color: false`. ```yaml ignore: diff --git a/src/cli.rs b/src/cli.rs index 5af0169..eb71a0f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -506,6 +506,7 @@ impl DiffParams { "json" => OutputFormat::Json, "yaml" => OutputFormat::Yaml, "sql" => OutputFormat::Sql, + "ci" => OutputFormat::Ci, _ => OutputFormat::Pretty, } } else { diff --git a/src/commands/diff.rs b/src/commands/diff.rs index 4db460d..874a67f 100644 --- a/src/commands/diff.rs +++ b/src/commands/diff.rs @@ -82,7 +82,7 @@ pub async fn run_diff(params: DiffParams) -> Result<(), ExitCode> { left.schema.sequences.clear(); } - if let Some(false) = cfg.output.color { + if matches!(params.color, dbdiff::cli::ColorMode::Auto) && cfg.output.color == Some(false) { colored::control::set_override(false); } diff --git a/src/config/mod.rs b/src/config/mod.rs index 960492b..bdc52ec 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -66,7 +66,7 @@ pub struct IgnoreConfig { #[derive(Debug, Clone, Default, Deserialize)] #[serde(default)] pub struct OutputConfig { - /// Output format: `pretty`, `json`, or `sql`. + /// Output format: `pretty`, `json`, `yaml`, `ci`, or `sql`. pub format: Option, /// Whether to use colored output. pub color: Option, diff --git a/tests/config.rs b/tests/config.rs index c667f5f..b31ea37 100644 --- a/tests/config.rs +++ b/tests/config.rs @@ -58,3 +58,60 @@ fn missing_config_file_uses_defaults() { .success() .stdout(predicate::str::contains("audit_log")); } + +#[test] +fn config_ci_format_and_cli_override() { + let dir = tempfile::tempdir().unwrap(); + let config = dir.path().join("config.yml"); + std::fs::write(&config, "output:\n format: ci\n").unwrap(); + for override_format in [false, true] { + let mut command = cmd(); + command + .args([ + "tests/fixtures/schema_a.sql", + "tests/fixtures/schema_b.sql", + "--config", + ]) + .arg(&config); + if override_format { + command.args(["--format", "json"]); + let output = command.assert().success().get_output().stdout.clone(); + assert!(serde_json::from_slice::(&output).is_ok()); + } else { + command + .assert() + .success() + .stdout(predicate::str::contains("CI summary:")); + } + } +} + +#[test] +fn explicit_color_mode_overrides_config() { + let dir = tempfile::tempdir().unwrap(); + let config = dir.path().join("config.yml"); + for configured in [false, true] { + std::fs::write(&config, format!("output:\n color: {configured}\n")).unwrap(); + for mode in ["always", "never", "auto"] { + let output = cmd() + .args([ + "tests/fixtures/schema_a.sql", + "tests/fixtures/schema_b.sql", + "--color", + mode, + "--config", + ]) + .arg(&config) + .assert() + .success() + .get_output() + .stdout + .clone(); + assert_eq!( + String::from_utf8(output).unwrap().contains("\x1b["), + mode == "always", + "config={configured}, mode={mode}" + ); + } + } +}