Skip to content

Commit

Permalink
Hide no-merge comments once merge commits removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Oct 15, 2024
1 parent b20366e commit 39b632c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/handlers/no_merges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pub(super) struct NoMergesInput {
struct NoMergesState {
/// Hashes of merge commits that have already been mentioned by triagebot in a comment.
mentioned_merge_commits: HashSet<String>,
/// List of all the no_merge comments as GitHub GraphQL NodeId.
#[serde(default)]
no_merge_comments: Vec<String>,
/// Labels that the bot added as part of the no-merges check.
#[serde(default)]
added_labels: Vec<String>,
Expand Down Expand Up @@ -124,10 +127,18 @@ pub(super) async fn handle_input(
.context("failed to remove label")?;
}

// FIXME: Minimize prior no_merges comments.
// Minimize prior no_merges comments.
for node_id in state.data.no_merge_comments.iter() {
event
.issue
.hide_comment(&ctx.github, node_id.as_str(), "no more merge commits")
.await
.context("failed to hide previous merge commit comment")?;
}

// Clear from state.
state.data.mentioned_merge_commits.clear();
state.data.no_merge_comments.clear();
state.data.added_labels.clear();
state.save().await?;
return Ok(());
Expand Down Expand Up @@ -202,11 +213,13 @@ pub(super) async fn handle_input(
.context("failed to set no_merges labels")?;

// Post comment
event
let comment = event
.issue
.post_comment(&ctx.github, &message)
.await
.context("failed to post no_merges comment")?;

state.data.no_merge_comments.push(comment.node_id);
state.save().await?;
}
Ok(())
Expand Down

0 comments on commit 39b632c

Please sign in to comment.