Skip to content

Commit 0a92f03

Browse files
committed
Add exclude labels pattern handling
This is to support not prioritizing issues tagged with `T-rustdoc`, `T-infra` and `T-release`.
1 parent f9ff127 commit 0a92f03

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub(crate) struct PrioritizeConfig {
8181
#[serde(default)]
8282
pub(crate) prioritize_on: Vec<String>,
8383
#[serde(default)]
84-
pub(crate) priority_labels: String,
84+
pub(crate) exclude_labels: Vec<String>,
8585
pub(crate) zulip_stream: u64,
8686
}
8787

src/handlers/prioritize.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,35 @@ impl Handler for PrioritizeHandler {
3535
if let Event::Issue(e) = event {
3636
if e.action == github::IssuesAction::Labeled {
3737
if let Some(config) = config {
38-
if e.label.as_ref().expect("label").name == config.label {
38+
let label_name = &e.label.as_ref().expect("label").name;
39+
40+
if *label_name == config.label {
3941
// We need to take the exact same action in this case.
4042
return Ok(Some(Prioritize::Start));
4143
} else {
42-
match glob::Pattern::new(&config.priority_labels) {
43-
Ok(glob) => {
44-
let issue_labels = event.issue().unwrap().labels();
45-
let label_name = &e.label.as_ref().expect("label").name;
46-
47-
if issue_labels.iter().all(|l| !glob.matches(&l.name))
48-
&& config.prioritize_on.iter().any(|l| l == label_name)
49-
{
50-
return Ok(Some(Prioritize::Label));
44+
if config.prioritize_on.iter().any(|l| l == label_name) {
45+
let mut prioritize = false;
46+
47+
for label in event.issue().unwrap().labels() {
48+
for exclude_label in &config.exclude_labels {
49+
match glob::Pattern::new(exclude_label) {
50+
Ok(exclude_glob) => {
51+
prioritize = !exclude_glob.matches(&label.name);
52+
}
53+
Err(error) => {
54+
log::error!("Invalid glob pattern: {}", error);
55+
}
56+
}
57+
58+
if !prioritize {
59+
break;
60+
}
5161
}
5262
}
53-
Err(error) => log::error!("Invalid glob pattern: {}", error),
63+
64+
if prioritize {
65+
return Ok(Some(Prioritize::Label));
66+
}
5467
}
5568
}
5669
}

0 commit comments

Comments
 (0)