Skip to content

Commit 9921cb0

Browse files
committed
Hide no-merge comments once merge commits removed
1 parent 2d280a1 commit 9921cb0

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/handlers/no_merges.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use crate::{
55
config::NoMergesConfig,
66
db::issue_data::IssueData,
7-
github::{IssuesAction, IssuesEvent, Label},
7+
github::{IssuesAction, IssuesEvent, Label, ReportedContentClassifiers},
88
handlers::Context,
99
};
1010
use anyhow::Context as _;
@@ -24,6 +24,9 @@ pub(super) struct NoMergesInput {
2424
struct NoMergesState {
2525
/// Hashes of merge commits that have already been mentioned by triagebot in a comment.
2626
mentioned_merge_commits: HashSet<String>,
27+
/// List of all the no_merge comments as GitHub GraphQL NodeId.
28+
#[serde(default)]
29+
no_merge_comments: Vec<String>,
2730
/// Labels that the bot added as part of the no-merges check.
2831
#[serde(default)]
2932
added_labels: Vec<String>,
@@ -124,10 +127,22 @@ pub(super) async fn handle_input(
124127
.context("failed to remove label")?;
125128
}
126129

127-
// FIXME: Minimize prior no_merges comments.
130+
// Minimize prior no_merges comments.
131+
for node_id in state.data.no_merge_comments.iter() {
132+
event
133+
.issue
134+
.hide_comment(
135+
&ctx.github,
136+
node_id.as_str(),
137+
ReportedContentClassifiers::Resolved,
138+
)
139+
.await
140+
.context("failed to hide previous merge commit comment")?;
141+
}
128142

129143
// Clear from state.
130144
state.data.mentioned_merge_commits.clear();
145+
state.data.no_merge_comments.clear();
131146
state.data.added_labels.clear();
132147
state.save().await?;
133148
return Ok(());
@@ -202,11 +217,13 @@ pub(super) async fn handle_input(
202217
.context("failed to set no_merges labels")?;
203218

204219
// Post comment
205-
event
220+
let comment = event
206221
.issue
207222
.post_comment(&ctx.github, &message)
208223
.await
209224
.context("failed to post no_merges comment")?;
225+
226+
state.data.no_merge_comments.push(comment.node_id);
210227
state.save().await?;
211228
}
212229
Ok(())

0 commit comments

Comments
 (0)