diff --git a/tools/changelog/src/cli.rs b/tools/changelog/src/cli.rs index 5eaf66c140a..99a10b00a2e 100644 --- a/tools/changelog/src/cli.rs +++ b/tools/changelog/src/cli.rs @@ -27,7 +27,7 @@ pub struct Cli { pub to: String, /// Path to changelog file - #[clap(short = 'f', long, default_value = "CHANGELOG.md")] + #[clap(short = 'f', long, default_value = "../CHANGELOG.md")] pub changelog_path: String, /// Skip writing changelog file diff --git a/tools/changelog/src/create_log_line.rs b/tools/changelog/src/create_log_line.rs index 28a06bf1127..25961e7e88f 100644 --- a/tools/changelog/src/create_log_line.rs +++ b/tools/changelog/src/create_log_line.rs @@ -6,12 +6,10 @@ use once_cell::sync::Lazy; use regex::Regex; use crate::github_issue_labels_fetcher::GitHubIssueLabelsFetcher; -use crate::github_user_fetcher::GitHubUsersFetcher; use crate::log_line::LogLine; static REGEX_FOR_ISSUE_ID_CAPTURE: Lazy = Lazy::new(|| Regex::new(r"\s*\(#(\d+)\)").unwrap()); -static GITHUB_USERS_FETCHER: Lazy> = Lazy::new(Default::default); static GITHUB_ISSUE_LABELS_FETCHER: Lazy> = Lazy::new(Default::default); @@ -21,6 +19,7 @@ pub fn create_log_line( oid: Result, token: Option, ) -> Result> { + println!("Commit oid: {:?}", oid); let oid = oid?; let commit = repo.find_commit(oid)?; let commit_first_line = commit @@ -31,9 +30,16 @@ pub fn create_log_line( .context("Missing commit message")? .to_string(); let author = commit.author(); + let author_name = author.name().unwrap_or("Unknown"); let email = author.email().context("Missing author's email")?; - if email.contains("dependabot") || email.contains("github-action") { + if email.contains("dependabot") { + println!("email contains dependabot"); + return Ok(None); + } + + if email.contains("github-action") { + println!("email contains github-action"); return Ok(None); } @@ -44,7 +50,7 @@ pub fn create_log_line( let captures = match mb_captures { Some(some) => some, None => { - eprintln!("Missing issue for commit: {}", oid); + eprintln!("Missing issue for commit: {oid}"); return Ok(None); } }; @@ -61,13 +67,6 @@ pub fn create_log_line( .as_str() .to_string(); - let user = GITHUB_USERS_FETCHER - .lock() - .map_err(|err| anyhow!("Failed to lock GITHUB_USERS_FETCHER: {}", err))? - .fetch_user_by_commit_author(email, oid.to_string(), token.clone()) - .with_context(|| format!("Could not find GitHub user for commit: {}", oid))? - .to_string(); - let issue_labels = GITHUB_ISSUE_LABELS_FETCHER .lock() .map_err(|err| anyhow!("Failed to lock GITHUB_ISSUE_LABELS_FETCHER: {}", err))? @@ -79,14 +78,17 @@ pub fn create_log_line( .any(|label| package_labels.contains(&label.as_str())); if !is_issue_for_this_package { + println!("Issue {issue_id} is not for {package_labels:?} packages"); return Ok(None); } let log_line = LogLine { message, - user, + user: author_name.to_string(), issue_id, }; + println!("{log_line:?}"); + Ok(Some(log_line)) } diff --git a/tools/changelog/src/log_line.rs b/tools/changelog/src/log_line.rs index d5ee1b6f3f5..e8d5596fd7c 100644 --- a/tools/changelog/src/log_line.rs +++ b/tools/changelog/src/log_line.rs @@ -1,3 +1,4 @@ +#[derive(Debug)] pub struct LogLine { pub message: String, pub user: String, diff --git a/tools/changelog/src/write_changelog_file.rs b/tools/changelog/src/write_changelog_file.rs index 23d12c3a8b7..bfd615530a7 100644 --- a/tools/changelog/src/write_changelog_file.rs +++ b/tools/changelog/src/write_changelog_file.rs @@ -9,7 +9,7 @@ pub fn write_changelog(changelog_path: &str, version_changelog: &[u8]) -> Result .context(format!("could not open {} for reading", changelog_path))?; let old_changelog_reader = BufReader::new(old_changelog); - let changelog_path_new = &format!("{}.new", changelog_path); + let changelog_path_new = &format!("../{}.new", changelog_path); let mut new_changelog = fs::OpenOptions::new() .write(true)