Skip to content
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

Use prioritize_on field to start prioritization process #542

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
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ pub(crate) struct RelabelConfig {
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
pub(crate) struct PrioritizeConfig {
pub(crate) label: String,
#[serde(default)]
pub(crate) prioritize_on: Vec<String>,
spastorino marked this conversation as resolved.
Show resolved Hide resolved
#[serde(default)]
pub(crate) priority_labels: String,
pub(crate) zulip_stream: u64,
}

Expand Down
26 changes: 19 additions & 7 deletions src/handlers/prioritize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ impl Handler for PrioritizeHandler {
if e.label.as_ref().expect("label").name == config.label {
// We need to take the exact same action in this case.
return Ok(Some(Prioritize::Start));
} else {
match glob::Pattern::new(&config.priority_labels) {
Ok(glob) => {
let issue_labels = event.issue().unwrap().labels();
let label_name = &e.label.as_ref().expect("label").name;

if issue_labels.iter().all(|l| !glob.matches(&l.name))
&& config.prioritize_on.iter().any(|l| l == label_name)
{
return Ok(Some(Prioritize::Label));
}
}
Err(error) => log::error!("Invalid glob pattern: {}", error),
}
}
}
}
Expand Down Expand Up @@ -100,13 +114,11 @@ async fn handle_input(
}
None
}
Prioritize::Start => {
Some(format!(
"@*WG-prioritization* issue [#{}]({}) has been requested for prioritization.",
issue.number,
event.html_url().unwrap()
))
}
Prioritize::Start => Some(format!(
"@*WG-prioritization* issue [#{}]({}) has been requested for prioritization.",
issue.number,
event.html_url().unwrap()
)),
Prioritize::End => {
// Shouldn't be necessary in practice as we only end on label
// removal, but if we add support in the future let's be sure to do
Expand Down