Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions src/core/repo_graph.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use std::fs;
use std::path::Path;
use toml::Value as TomlValue;

mod builder;
mod generic;
mod go;
mod helpers;
mod impact;
mod manifest;
mod node;
mod python;
mod rust;
mod types;

use builder::RepoGraphBuilder;
use helpers::{display_path, normalize_path};
use helpers::display_path;

pub use impact::analyze_impact;
pub use types::*;
Expand Down Expand Up @@ -66,18 +66,3 @@ fn detect_ignored_paths(root: &Path, builder: &mut RepoGraphBuilder) {
}
}
}

fn manifest_warning_category(message: &str) -> DetectionCategory {
if message.starts_with("Failed to read") {
DetectionCategory::UnreadableManifest
} else {
DetectionCategory::MalformedManifest
}
}

fn read_toml(path: &Path) -> Result<TomlValue, String> {
fs::read_to_string(path)
.map_err(|error| format!("Failed to read {}: {error}", normalize_path(path)))?
.parse::<TomlValue>()
.map_err(|error| format!("Failed to parse {}: {error}", normalize_path(path)))
}
22 changes: 22 additions & 0 deletions src/core/repo_graph/manifest.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use std::fs;
use std::path::Path;

use toml::Value as TomlValue;

use super::helpers::normalize_path;
use super::types::DetectionCategory;

pub(super) fn manifest_warning_category(message: &str) -> DetectionCategory {
if message.starts_with("Failed to read") {
DetectionCategory::UnreadableManifest
} else {
DetectionCategory::MalformedManifest
}
}

pub(super) fn read_toml(path: &Path) -> Result<TomlValue, String> {
fs::read_to_string(path)
.map_err(|error| format!("Failed to read {}: {error}", normalize_path(path)))?
.parse::<TomlValue>()
.map_err(|error| format!("Failed to parse {}: {error}", normalize_path(path)))
}
3 changes: 2 additions & 1 deletion src/core/repo_graph/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::fs;
use std::path::Path;

use super::helpers::normalize_path;
use super::manifest::manifest_warning_category;
use super::types::*;
use super::{manifest_warning_category, RepoGraphBuilder};
use super::RepoGraphBuilder;

pub(super) fn detect_node(root: &Path, builder: &mut RepoGraphBuilder) {
let package_json = root.join("package.json");
Expand Down
3 changes: 2 additions & 1 deletion src/core/repo_graph/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use std::fs;
use std::path::Path;
use toml::Value as TomlValue;

use super::manifest::{manifest_warning_category, read_toml};
use super::types::*;
use super::{manifest_warning_category, read_toml, RepoGraphBuilder};
use super::RepoGraphBuilder;

pub(super) fn detect_python(root: &Path, builder: &mut RepoGraphBuilder) {
let mut python_project_detected = false;
Expand Down
3 changes: 2 additions & 1 deletion src/core/repo_graph/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::path::{Path, PathBuf};
use toml::Value as TomlValue;

use super::helpers::{normalize_path, stable_id};
use super::manifest::{manifest_warning_category, read_toml};
use super::types::*;
use super::{manifest_warning_category, read_toml, RepoGraphBuilder};
use super::RepoGraphBuilder;

struct CargoWorkspaceMember {
relative_manifest: PathBuf,
Expand Down