-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't ping everyone on rebase mistakes #1672
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ use tracing as log; | |
const MENTIONS_KEY: &str = "mentions"; | ||
|
||
pub(super) struct MentionsInput { | ||
has_bors_commit: bool, | ||
paths: Vec<String>, | ||
} | ||
|
||
|
@@ -50,6 +51,17 @@ pub(super) async fn parse_input( | |
return Ok(None); | ||
} | ||
|
||
let has_bors_commit = event.action == IssuesAction::Opened | ||
&& config.bors_commit_message.is_some() | ||
&& event | ||
.issue | ||
.commits(&ctx.github) | ||
.await | ||
.map_err(|e| log::error!("failed to fetch commits: {:?}", e)) | ||
.unwrap_or_default() | ||
.into_iter() | ||
.any(|commit| commit.commit.author.name == "bors"); | ||
Comment on lines
+54
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this even work for problematic rebases? As someone pointed out on Zulip, https://github.com/rust-lang/rust/pull/103918/commits does not have any bors-authored commits. |
||
|
||
if let Some(diff) = event | ||
.issue | ||
.diff(&ctx.github) | ||
|
@@ -78,7 +90,10 @@ pub(super) async fn parse_input( | |
.map(|(key, _mention)| key.to_string()) | ||
.collect(); | ||
if !to_mention.is_empty() { | ||
return Ok(Some(MentionsInput { paths: to_mention })); | ||
return Ok(Some(MentionsInput { | ||
has_bors_commit, | ||
paths: to_mention, | ||
})); | ||
} | ||
} | ||
Ok(None) | ||
|
@@ -95,6 +110,14 @@ pub(super) async fn handle_input( | |
IssueData::load(&mut client, &event.issue, MENTIONS_KEY).await?; | ||
// Build the message to post to the issue. | ||
let mut result = String::new(); | ||
if input.has_bors_commit { | ||
write!( | ||
result, | ||
"{}\n", | ||
config.bors_commit_message.as_deref().unwrap() | ||
) | ||
.unwrap(); | ||
} | ||
for to_mention in &input.paths { | ||
if state.data.paths.iter().any(|p| p == to_mention) { | ||
// Avoid duplicate mentions. | ||
|
@@ -109,6 +132,11 @@ pub(super) async fn handle_input( | |
None => write!(result, "Some changes occurred in {to_mention}").unwrap(), | ||
} | ||
if !cc.is_empty() { | ||
let cc: Vec<String> = if input.has_bors_commit { | ||
cc.iter().map(|s| format!("`{s}`")).collect() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Zulip there was a proposal to also mark the PR as draft, to prevent it from being merge. Ideally we'd want a scheme where the pings definitely happen when the PR gets approved or lands, but I am not sure if that is possible. EDIT: Ah I saw that was already discussed and doesn't seem possible. Bummer. |
||
} else { | ||
cc.to_owned() | ||
}; | ||
write!(result, "\n\ncc {}", cc.join(", ")).unwrap(); | ||
} | ||
state.data.paths.push(to_mention.to_string()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could this middle test possibly fail?
This test should be over the overall output, not the config system