tidy/
triagebot.rs
1use std::path::Path;
4
5use toml::Value;
6
7pub fn check(path: &Path, bad: &mut bool) {
8 let triagebot_path = path.join("triagebot.toml");
9 if !triagebot_path.exists() {
10 tidy_error!(bad, "triagebot.toml file not found");
11 return;
12 }
13
14 let contents = std::fs::read_to_string(&triagebot_path).unwrap();
15 let config: Value = toml::from_str(&contents).unwrap();
16
17 if let Some(Value::Table(mentions)) = config.get("mentions") {
19 for path_str in mentions.keys() {
20 let clean_path = path_str.trim_matches('"');
22 let full_path = path.join(clean_path);
23
24 if !full_path.exists() {
25 tidy_error!(
26 bad,
27 "triagebot.toml [mentions.*] contains path '{}' which doesn't exist",
28 clean_path
29 );
30 }
31 }
32 } else {
33 tidy_error!(
34 bad,
35 "triagebot.toml missing [mentions.*] section, this wrong for rust-lang/rust repo."
36 );
37 }
38
39 if let Some(Value::Table(assign)) = config.get("assign") {
43 if let Some(Value::Table(owners)) = assign.get("owners") {
44 for path_str in owners.keys() {
45 let clean_path = path_str.trim_matches('"').trim_start_matches('/');
47 let full_path = path.join(clean_path);
48
49 if !full_path.exists() {
50 tidy_error!(
51 bad,
52 "triagebot.toml [assign.owners] contains path '{}' which doesn't exist",
53 clean_path
54 );
55 }
56 }
57 } else {
58 tidy_error!(
59 bad,
60 "triagebot.toml missing [assign.owners] section, this wrong for rust-lang/rust repo."
61 );
62 }
63 }
64
65 if let Some(Value::Table(autolabels)) = config.get("autolabel") {
73 for (label, content) in autolabels {
74 if let Some(trigger_files) = content.get("trigger_files").and_then(|v| v.as_array()) {
75 for file in trigger_files {
76 if let Some(file_str) = file.as_str() {
77 let full_path = path.join(file_str);
78
79 if !full_path.exists() {
81 tidy_error!(
82 bad,
83 "triagebot.toml [autolabel.{}] contains trigger_files path '{}' which doesn't exist",
84 label,
85 file_str
86 );
87 }
88 }
89 }
90 }
91 }
92 }
93}