Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/rust-project-goals-cli/src/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
16 changes: 15 additions & 1 deletion crates/rust-project-goals/src/gh/issues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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)
}
Expand All @@ -497,6 +510,7 @@ impl From<ExistingGithubIssueJson> for ExistingGithubIssue {
body: c.body,
url: c.url,
created_at: c.created_at,
hidden: c.is_minimized,
})
.collect(),
body: e_i.body,
Expand Down