Skip to content

Commit 61c73ca

Browse files
bors[bot]lnicola
andauthored
Merge #7836
7836: Check for path dev-dependencies with a version number r=lnicola a=lnicola Closes #7828 (comment). This looks a bit ugly, but at least fixes an issues where we missed target-specific dependencies. Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents 2183d65 + 203cfff commit 61c73ca

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

xtask/src/tidy.rs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,44 @@ fn cargo_files_are_tidy() {
101101
let mut section = None;
102102
for (line_no, text) in read_file(&cargo).unwrap().lines().enumerate() {
103103
let text = text.trim();
104-
if text.starts_with("[") {
104+
if text.starts_with('[') {
105+
if !text.ends_with(']') {
106+
panic!(
107+
"\nplease don't add comments or trailing whitespace in section lines.\n\
108+
{}:{}\n",
109+
cargo.display(),
110+
line_no + 1
111+
)
112+
}
105113
section = Some(text);
106114
continue;
107115
}
108-
if !section.map(|it| it.starts_with("[dependencies")).unwrap_or(false) {
116+
let text: String = text.split_whitespace().collect();
117+
if !text.contains("path=") {
109118
continue;
110119
}
111-
let text: String = text.split_whitespace().collect();
112-
if text.contains("path=") && !text.contains("version") {
113-
panic!(
114-
"\ncargo internal dependencies should have version.\n\
115-
{}:{}\n",
116-
cargo.display(),
117-
line_no + 1
118-
)
120+
match section {
121+
Some(s) if s.contains("dev-dependencies") => {
122+
if text.contains("version") {
123+
panic!(
124+
"\ncargo internal dev-dependencies should not have a version.\n\
125+
{}:{}\n",
126+
cargo.display(),
127+
line_no + 1
128+
);
129+
}
130+
}
131+
Some(s) if s.contains("dependencies") => {
132+
if !text.contains("version") {
133+
panic!(
134+
"\ncargo internal dependencies should have a version.\n\
135+
{}:{}\n",
136+
cargo.display(),
137+
line_no + 1
138+
);
139+
}
140+
}
141+
_ => {}
119142
}
120143
}
121144
}

0 commit comments

Comments
 (0)