1use std::collections::{BTreeMap, BTreeSet};
3use std::io::{BufRead, BufReader, LineWriter, Lines, Write};
5use std::process::Command;
10 handle(true, |loc, _lines| match loc {
11 // Add empty array to keep yaml valid
12 Location::Lib => vec![" []".to_owned()],
13 Location::Test | Location::Bench => vec![],
17pub fn add(lib: Vec<String>, test: Vec<String>, bench: Vec<String>) {
18 handle(true, |loc, mut lines| {
19 lines.extend(match loc {
20 Location::Lib => lib.clone(),
21 Location::Test => test.clone(),
22 Location::Bench => bench.clone(),
31 handle(false, |_loc, lines| {
35 let mut map = BTreeMap::new();
36 let mut support: BTreeMap<(String, String), BTreeSet<(String, String)>> = BTreeMap::new();
37 for v in all.into_iter() {
38 let caps = regex!("tried ([^ ]+)-([^,-]+),").captures(&v).unwrap();
39 let package = caps.get(1).unwrap().as_str().to_owned();
40 let version = caps.get(2).unwrap().as_str().to_owned();
41 map.insert(package.clone(), version.clone());
43 if let Some(caps) = regex!("does not support: ([^ ]+)-([^-]+)").captures(&v) {
44 let dep_package = caps.get(1).unwrap().as_str().to_owned();
45 let dep_version = caps.get(2).unwrap().as_str().to_owned();
47 .entry((dep_package, dep_version))
49 entry.insert((package, version));
53 let entries = map.len() + support.len();
56 for (package, version) in map {
58 println!("{:02}%", ((i as f64 / entries as f64) * 100.0).floor());
61 let latest = latest_version(&package);
62 if version != latest {
64 "{} mismatch, snapshot: {}, hackage: {}",
65 package, version, latest
70 for ((package, version), dependents) in support {
72 println!("{:02}%", ((i as f64 / entries as f64) * 100.0).floor());
75 let latest = latest_version(&package);
76 if version != latest {
78 "{} mismatch, snapshot: {}, hackage: {}, dependents: {}",
84 .map(|(p, v)| format!("{}-{}", p, v))
85 .collect::<Vec<String>>()
92fn latest_version(pkg: &str) -> String {
94 Command::new("latest-version")
108 LookingForTestBounds,
109 ProcessingTestBounds,
110 LookingForBenchBounds,
111 ProcessingBenchBounds,
115fn handle<F>(write: bool, mut f: F)
117 F: FnMut(Location, Vec<String>) -> Vec<String>,
119 let path = "build-constraints.yaml";
120 let mut new_lines: Vec<String> = vec![];
122 let mut state = State::LookingForLibBounds;
123 let mut buf = vec![];
124 for line in read_lines(path).map(|s| s.unwrap()) {
126 State::LookingForLibBounds => {
127 if line == r#" "Library and exe bounds failures":"# {
128 state = State::ProcessingLibBounds;
130 new_lines.push(line);
132 State::ProcessingLibBounds => {
133 if line == r#" # End of Library and exe bounds failures"# {
134 new_lines.extend(f(Location::Lib, buf).into_iter());
136 new_lines.push(line);
137 state = State::LookingForTestBounds;
139 // Remove empty section
145 State::LookingForTestBounds => {
146 if line == r#" # Test bounds issues"# {
147 state = State::ProcessingTestBounds;
149 new_lines.push(line);
151 State::ProcessingTestBounds => {
152 if line == r#" # End of Test bounds issues"# {
153 new_lines.extend(f(Location::Test, buf).into_iter());
155 new_lines.push(line);
156 state = State::LookingForBenchBounds;
161 State::LookingForBenchBounds => {
162 if line == r#" # Benchmark bounds issues"# {
163 state = State::ProcessingBenchBounds;
165 new_lines.push(line);
167 State::ProcessingBenchBounds => {
168 if line == r#" # End of Benchmark bounds issues"# {
169 new_lines.extend(f(Location::Bench, buf).into_iter());
171 new_lines.push(line);
178 new_lines.push(line);
184 let file = File::create(path).unwrap();
185 let mut file = LineWriter::new(file);
187 for line in new_lines {
188 file.write_all((line + "\n").as_bytes()).unwrap();
190 file.flush().unwrap();
200fn read_lines<P>(filename: P) -> Lines<BufReader<File>>
204 let file = File::open(filename).unwrap();
205 BufReader::new(file).lines()
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list