-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_parse.rs
More file actions
58 lines (50 loc) · 1.78 KB
/
debug_parse.rs
File metadata and controls
58 lines (50 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use std::fs;
fn main() -> anyhow::Result<()> {
let content = fs::read_to_string("/tmp/tree_debug.txt")?;
let dependencies = parse_dependency_tree(&content)?;
println!("Total dependencies found: {}", dependencies.len());
println!(
"Dependencies containing 'rustls': {:?}",
dependencies
.iter()
.filter(|d| d.contains("rustls"))
.collect::<Vec<_>>()
);
// Check if rustls is directly present
if dependencies.contains(&"rustls".to_string()) {
println!("✓ rustls found in dependencies");
} else {
println!("✗ rustls NOT found in dependencies");
}
// Show first 20 dependencies
println!(
"First 20 dependencies: {:?}",
&dependencies[..std::cmp::min(20, dependencies.len())]
);
Ok(())
}
/// Helper function to parse cargo tree output and extract dependency names
fn parse_dependency_tree(tree_output: &str) -> anyhow::Result<Vec<String>> {
let dependencies = tree_output
.lines()
.filter_map(|line| {
// Remove tree drawing characters and extract package name
let cleaned = line.trim_start_matches(&['├', '│', '└', '─', ' '][..]);
// Parse lines like "mysql v26.0.1" or "native-tls v0.2.11"
if let Some(first_space) = cleaned.find(' ') {
let dep_name = &cleaned[..first_space];
if !dep_name.is_empty() {
Some(dep_name.to_string())
} else {
None
}
} else if !cleaned.is_empty() {
// Handle lines with just the package name
Some(cleaned.to_string())
} else {
None
}
})
.collect();
Ok(dependencies)
}