~jplatte/cargo-depgraph

bf85f890e0b0dde4278029ad4989c3e23bd5c181 — Jonas Platte 5 months ago dbf18fa
Fix --exclude not working for workspace members
3 files changed, 10 insertions(+), 2 deletions(-)

M CHANGELOG.md
M src/graph.rs
M src/graph/builder.rs
M CHANGELOG.md => CHANGELOG.md +4 -0
@@ 1,3 1,7 @@
# [unreleased]

* Fix `--exclude` not working for workspace members

# 1.2.1

* Calculate dependency kinds correctly in all cases

M src/graph.rs => src/graph.rs +1 -1
@@ 17,7 17,7 @@ pub type DepGraph = StableDiGraph<Package, DepInfo, u16>;

pub fn get_dep_graph(metadata: Metadata, config: &Config) -> anyhow::Result<DepGraph> {
    let mut builder = DepGraphBuilder::new(metadata)?;
    builder.add_workspace_members()?;
    builder.add_workspace_members(config)?;
    builder.add_dependencies(config)?;

    Ok(builder.graph)

M src/graph/builder.rs => src/graph/builder.rs +5 -1
@@ 49,9 49,13 @@ impl DepGraphBuilder {
        })
    }

    pub fn add_workspace_members(&mut self) -> anyhow::Result<()> {
    pub fn add_workspace_members(&mut self, config: &Config) -> anyhow::Result<()> {
        for pkg_id in &self.workspace_members {
            let pkg = get_package(&self.packages, pkg_id);
            if config.exclude.contains(&pkg.name) {
                continue;
            }

            let node_idx = self.graph.add_node(Package::new(pkg, true));
            self.deps_add_queue.push_back(pkg_id.clone());
            let old_val = self.node_indices.insert(pkg_id.clone(), node_idx);