diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc749ac..9c8b650 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,13 @@ cargo build cargo test ``` -6. Make sure [rustfmt](https://github.com/rust-lang/rustfmt) and [clippy](https://github.com/rust-lang/rust-clippy) don't complain about your changes. +6. If needed, update the snapshot tests (i.e. tests using `expect_test`): + +```sh +env UPDATE_EXPECT=1 cargo test +``` + +7. Make sure [rustfmt](https://github.com/rust-lang/rustfmt) and [clippy](https://github.com/rust-lang/rust-clippy) don't complain about your changes. We use the `nightly` channel for `rustfmt` so please set the appropriate settings for your editor/IDE for that. diff --git a/Cargo.lock b/Cargo.lock index 9ccb5bd..9af7b6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -521,6 +521,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "dissimilar" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" + [[package]] name = "doc-comment" version = "0.3.3" @@ -586,6 +592,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "expect-test" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e0be0a561335815e06dab7c62e50353134c796e7a6155402a64bcff66b6a5e0" +dependencies = [ + "dissimilar", + "once_cell", +] + [[package]] name = "fastrand" version = "2.0.2" @@ -761,6 +777,7 @@ dependencies = [ "config", "dirs", "document-features", + "expect-test", "futures", "git-conventional", "git2", diff --git a/git-cliff-core/Cargo.toml b/git-cliff-core/Cargo.toml index 608c53a..507be33 100644 --- a/git-cliff-core/Cargo.toml +++ b/git-cliff-core/Cargo.toml @@ -80,6 +80,7 @@ features = ["debug-embed", "compression"] [dev-dependencies] pretty_assertions = "1.4.0" +expect-test = "1.5.0" [package.metadata.docs.rs] all-features = true diff --git a/git-cliff-core/src/changelog.rs b/git-cliff-core/src/changelog.rs index 662c306..8760eac 100644 --- a/git-cliff-core/src/changelog.rs +++ b/git-cliff-core/src/changelog.rs @@ -28,10 +28,11 @@ use std::time::{ #[derive(Debug)] pub struct Changelog<'a> { /// Releases that the changelog will contain. - pub releases: Vec>, - body_template: Template, - footer_template: Option