Skip to content

Commit

Permalink
Use prioritize_on field to start prioritization process
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed May 14, 2020
1 parent 5285ce7 commit 894516d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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>,
#[serde(default)]
pub(crate) priority_labels: String,
pub(crate) zulip_stream: u64,
}

Expand Down
12 changes: 12 additions & 0 deletions src/handlers/prioritize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ 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 {
if let Ok(glob) = glob::Pattern::new(&config.priority_labels) {
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)
{
// We need to take the exact same action in this case.
return Ok(Some(Prioritize::Start));
}
}
}
}
}
Expand Down

0 comments on commit 894516d

Please sign in to comment.