Skip to content

Commit 965abda

Browse files
authored
Merge pull request #421 from lqd/filter-hidden-comments
filter out hidden comments from reports
2 parents a252853 + a30128f commit 965abda

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

crates/rust-project-goals-cli/src/updates.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ fn prepare_goals(
231231

232232
let mut comments = issue.comments.clone();
233233
comments.sort_by_key(|c| c.created_at.clone());
234-
comments.retain(|c| !c.is_automated_comment() && filter.matches(c));
234+
comments.retain(|c| !c.should_hide_from_reports() && filter.matches(c));
235+
235236
// Prettify the comments' timestamp after using it for sorting.
236237
for comment in comments.iter_mut() {
237238
comment.created_at = format!("{}", comment.created_at_date());

crates/rust-project-goals/src/gh/issues.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct ExistingGithubComment {
2929
pub body: String,
3030
pub created_at: String,
3131
pub url: String,
32+
hidden: bool,
3233
}
3334

3435
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
@@ -56,6 +57,9 @@ struct ExistingGithubCommentJson {
5657
#[serde(rename = "createdAt")]
5758
created_at: String,
5859
url: String,
60+
/// Whether a comment was marked "hidden" on the GH UI.
61+
#[serde(rename = "isMinimized")]
62+
is_minimized: bool,
5963
}
6064

6165
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
@@ -471,8 +475,17 @@ pub fn lock_issue(repository: &Repository, number: u64) -> Result<()> {
471475
}
472476

473477
impl ExistingGithubComment {
478+
/// Some comments are not actually updates we want to use in progress reports. For example,
479+
/// automated comments when rotating goal periods, or random comments on the tracking issues.
480+
/// The former are kinda possible to detect (this tool generates them in the first place) and to
481+
/// support filtering out the other cases, we'll just ignore comments that were marked as hidden
482+
/// on github.
483+
pub fn should_hide_from_reports(&self) -> bool {
484+
self.is_automated_comment() || self.hidden
485+
}
486+
474487
/// True if this is one of the special comments that we put on issues.
475-
pub fn is_automated_comment(&self) -> bool {
488+
fn is_automated_comment(&self) -> bool {
476489
let trimmed_body = self.body.trim();
477490
trimmed_body == LOCK_TEXT || trimmed_body.starts_with(CONTINUING_GOAL_PREFIX)
478491
}
@@ -497,6 +510,7 @@ impl From<ExistingGithubIssueJson> for ExistingGithubIssue {
497510
body: c.body,
498511
url: c.url,
499512
created_at: c.created_at,
513+
hidden: c.is_minimized,
500514
})
501515
.collect(),
502516
body: e_i.body,

0 commit comments

Comments
 (0)