From a30128f158157fe5018b222de869d8f0f0cfe942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Wed, 1 Oct 2025 10:33:41 +0000 Subject: [PATCH] filter out hidden comments from reports --- crates/rust-project-goals-cli/src/updates.rs | 3 ++- crates/rust-project-goals/src/gh/issues.rs | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/rust-project-goals-cli/src/updates.rs b/crates/rust-project-goals-cli/src/updates.rs index f5884ef9..2ceb7a7c 100644 --- a/crates/rust-project-goals-cli/src/updates.rs +++ b/crates/rust-project-goals-cli/src/updates.rs @@ -231,7 +231,8 @@ fn prepare_goals( let mut comments = issue.comments.clone(); comments.sort_by_key(|c| c.created_at.clone()); - comments.retain(|c| !c.is_automated_comment() && filter.matches(c)); + comments.retain(|c| !c.should_hide_from_reports() && filter.matches(c)); + // Prettify the comments' timestamp after using it for sorting. for comment in comments.iter_mut() { comment.created_at = format!("{}", comment.created_at_date()); diff --git a/crates/rust-project-goals/src/gh/issues.rs b/crates/rust-project-goals/src/gh/issues.rs index 4d87702f..b86c0cf1 100644 --- a/crates/rust-project-goals/src/gh/issues.rs +++ b/crates/rust-project-goals/src/gh/issues.rs @@ -29,6 +29,7 @@ pub struct ExistingGithubComment { pub body: String, pub created_at: String, pub url: String, + hidden: bool, } #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] @@ -56,6 +57,9 @@ struct ExistingGithubCommentJson { #[serde(rename = "createdAt")] created_at: String, url: String, + /// Whether a comment was marked "hidden" on the GH UI. + #[serde(rename = "isMinimized")] + is_minimized: bool, } #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] @@ -471,8 +475,17 @@ pub fn lock_issue(repository: &Repository, number: u64) -> Result<()> { } impl ExistingGithubComment { + /// Some comments are not actually updates we want to use in progress reports. For example, + /// automated comments when rotating goal periods, or random comments on the tracking issues. + /// The former are kinda possible to detect (this tool generates them in the first place) and to + /// support filtering out the other cases, we'll just ignore comments that were marked as hidden + /// on github. + pub fn should_hide_from_reports(&self) -> bool { + self.is_automated_comment() || self.hidden + } + /// True if this is one of the special comments that we put on issues. - pub fn is_automated_comment(&self) -> bool { + fn is_automated_comment(&self) -> bool { let trimmed_body = self.body.trim(); trimmed_body == LOCK_TEXT || trimmed_body.starts_with(CONTINUING_GOAL_PREFIX) } @@ -497,6 +510,7 @@ impl From for ExistingGithubIssue { body: c.body, url: c.url, created_at: c.created_at, + hidden: c.is_minimized, }) .collect(), body: e_i.body,