Skip to content

Commit

Permalink
format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jellllly420 committed May 1, 2023
1 parent ff6cd17 commit 721e983
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
20 changes: 14 additions & 6 deletions tools/changelog/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ impl Cli {
let (breaking_changes, filtered_log_lines): (Vec<_>, Vec<_>) = log_lines
.into_iter()
.partition(|log_line| log_line.is_breaking_change);

let (fixes, features): (Vec<_>, Vec<_>) = filtered_log_lines
.into_iter()
.partition(|filtered_log_line| filtered_log_line.message.to_lowercase().contains("fix"));

let (fixes, features): (Vec<_>, Vec<_>) =
filtered_log_lines
.into_iter()
.partition(|filtered_log_line| {
filtered_log_line.message.to_lowercase().contains("fix")
});

// create displayable log lines
let fixes_logs = write_log_lines(fixes)?;
Expand All @@ -96,8 +99,13 @@ impl Cli {

if !skip_file_write {
// create version changelog
let version_changelog =
write_changelog_file(&fixes_logs, &features_logs, &breaking_changes_logs, package, next_version)?;
let version_changelog = write_changelog_file(
&fixes_logs,
&features_logs,
&breaking_changes_logs,
package,
next_version,
)?;

// write changelog
write_changelog(&changelog_path, &version_changelog)?;
Expand Down
6 changes: 3 additions & 3 deletions tools/changelog/src/stdout_tag_description_changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::io::{stdout, Write};
use anyhow::Result;

pub fn stdout_tag_description_changelog(
fixes_logs: &[u8],
features_logs: &[u8],
breaking_changes_logs: &[u8]
fixes_logs: &[u8],
features_logs: &[u8],
breaking_changes_logs: &[u8],
) -> Result<()> {
let mut tag_changelog = Vec::new();

Expand Down
25 changes: 11 additions & 14 deletions tools/changelog/tests/generate_yew_changelog_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ fn generate_yew_changelog_file() -> Result<()> {
fs::copy("tests/test_base.md", "tests/test_changelog.md")?;

// Run
_generate_yew_changelog_file("abeb8bc3f1ffabc8a58bd9ba4430cd091a06335a",
"d8ec50150ed27e2835bb1def26d2371a8c2ab750")?;
_generate_yew_changelog_file(
"abeb8bc3f1ffabc8a58bd9ba4430cd091a06335a",
"d8ec50150ed27e2835bb1def26d2371a8c2ab750",
)?;

_generate_yew_changelog_file("8086a73a217a099a46138f4363411827b18d1cb0",
"934aedbc8815fd77fc6630b644cfea4f9a071236")?;
_generate_yew_changelog_file(
"8086a73a217a099a46138f4363411827b18d1cb0",
"934aedbc8815fd77fc6630b644cfea4f9a071236",
)?;

// Check
let expected = File::open("tests/test_expected.md")?;
Expand All @@ -58,20 +62,13 @@ fn generate_yew_changelog_file() -> Result<()> {
let lines = expected_reader_lines.zip(after_reader_lines);

for (i, (expected_line, after_line)) in lines.enumerate() {
if i == 2 {
if i == 2 || i == 13 {
// third line has dynamic things that may break the tests
let expected_third_line = expected_line?.replace(
let expected_line_updated = expected_line?.replace(
"date_goes_here",
Utc::now().format("%Y-%m-%d").to_string().as_str(),
);
assert_eq!(expected_third_line, after_line?);
} else if i == 13 {
// thirteenth line has dynamic things that may break the tests
let expected_thirteenth_line = expected_line?.replace(
"date_goes_here",
Utc::now().format("%Y-%m-%d").to_string().as_str(),
);
assert_eq!(expected_thirteenth_line, after_line?);
assert_eq!(expected_line_updated, after_line?);
} else {
assert_eq!(expected_line?, after_line?);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/changelog/tests/test_expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

### 🛠 Fixes

- Fix defaulted type parameter.. [[@futursolo](https://github.com/futursolo), [#2284](https://github.com/yewstack/yew/pull/2284)]
- Fix defaulted type parameter.. [[@Kaede Hoshikawa](https://github.com/Kaede Hoshikawa), [#2284](https://github.com/yewstack/yew/pull/2284)]

### ⚡️ Features

Expand Down

0 comments on commit 721e983

Please sign in to comment.