aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2021-03-01 19:13:16 +0000
committerLaurenČ›iu Nicola <[email protected]>2021-03-01 19:13:16 +0000
commit203cfff8265b10fe4b428fb1d9b8166239cedbd4 (patch)
treea35e26d9e7fef682ab1f373ffae95c7f1ff297be
parent9860a396035f61a5cc9265c1104a640547bded51 (diff)
Check for path dev-dependencies with a version number
-rw-r--r--xtask/src/tidy.rs43
1 files changed, 33 insertions, 10 deletions
diff --git a/xtask/src/tidy.rs b/xtask/src/tidy.rs
index 63116ec6b..349ca14d0 100644
--- a/xtask/src/tidy.rs
+++ b/xtask/src/tidy.rs
@@ -101,21 +101,44 @@ fn cargo_files_are_tidy() {
101 let mut section = None; 101 let mut section = None;
102 for (line_no, text) in read_file(&cargo).unwrap().lines().enumerate() { 102 for (line_no, text) in read_file(&cargo).unwrap().lines().enumerate() {
103 let text = text.trim(); 103 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 }
105 section = Some(text); 113 section = Some(text);
106 continue; 114 continue;
107 } 115 }
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=") {
109 continue; 118 continue;
110 } 119 }
111 let text: String = text.split_whitespace().collect(); 120 match section {
112 if text.contains("path=") && !text.contains("version") { 121 Some(s) if s.contains("dev-dependencies") => {
113 panic!( 122 if text.contains("version") {
114 "\ncargo internal dependencies should have version.\n\ 123 panic!(
115 {}:{}\n", 124 "\ncargo internal dev-dependencies should not have a version.\n\
116 cargo.display(), 125 {}:{}\n",
117 line_no + 1 126 cargo.display(),
118 ) 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 _ => {}
119 } 142 }
120 } 143 }
121 } 144 }