Thanks to visit codestin.com
Credit goes to github.com

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
480 changes: 190 additions & 290 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-hackerman"
version = "0.2.8"
version = "0.2.9"
edition = "2021"
description = "Workspace hack management and package/feature query"
license = "MIT OR Apache-2.0"
Expand All @@ -11,18 +11,18 @@ exclude = ["TODO", "test_workspaces"]

[dependencies]
anyhow = "1.0.52"
bpaf = { version = "0.9.2", features = ["derive", "autocomplete", "docgen"] }
bpaf = { version = "0.9.9", features = ["derive", "autocomplete", "docgen"] }
cargo-platform = "0.1"
cargo_metadata = { version = "0.17" }
cargo_metadata = { version = "0.18" }
dot = "0.1.4"
pathdiff = { version = "0.2", features = ["camino"] }
petgraph = "0.6.0"
semver = "1.0"
serde = "<=1.0.171"
serde = "=1.0.196"
serde_json = "1.0"
target-spec = "3.0"
tempfile = { version = "3.3.0" }
toml_edit = "0.19"
toml_edit = "0.21"
tracing = "0.1.29"
tracing-subscriber = { version = "0.3.5", default-features = false, features = [ "alloc", "env-filter", "registry", "std", "fmt" ] }
webbrowser = { version = "0.8.10", optional = true }
Expand Down
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## [0.2.9] - 2024-02-05
- Features of build dependencies should not be unified with normal dependencies
- bump bpaf

## [0.2.8] - 2023-08-27
- refuse to hack already hacked files
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ sequentially
* [`cargo hackerman tree`↴](#cargo-hackerman-tree)
* [`cargo hackerman show`↴](#cargo-hackerman-show)

# cargo hackerman
## cargo hackerman

A collection of tools that help your workspace to compile fast

Expand Down Expand Up @@ -213,7 +213,7 @@ A collection of tools that help your workspace to compile fast
You can pass **`--help`** twice for more detailed help


# cargo hackerman hack
## cargo hackerman hack

Unify crate dependencies across individual crates in the workspace

Expand Down Expand Up @@ -263,7 +263,7 @@ You can undo those changes using `cargo hackerman restore`.
Once dependencies are hacked you should restore them before making any changes.


# cargo hackerman restore
## cargo hackerman restore

Remove crate dependency unification added by the `hack` command

Expand Down Expand Up @@ -294,7 +294,7 @@ Remove crate dependency unification added by the `hack` command
Prints help information


# cargo hackerman check
## cargo hackerman check

Check if unification is required and if checksums are correct

Expand Down Expand Up @@ -323,7 +323,7 @@ Similar to `cargo-hackerman hack --dry`, but also sets exit status to 1 so you c
Prints help information


# cargo hackerman merge
## cargo hackerman merge

Restore files and merge with the default merge driver

Expand All @@ -350,7 +350,7 @@ And something like this to `.git/gitattributes`
Cargo.toml merge=hackerman
```

# cargo hackerman explain
## cargo hackerman explain

Explain why some dependency is present. Both feature and version are optional

Expand Down Expand Up @@ -393,7 +393,7 @@ If a crate is present in several versions you can specify version of the one you
You can also specify which feature to look for, otherwise hackerman will be looking for all of them.


# cargo hackerman dupes
## cargo hackerman dupes

Lists all the duplicates in the workspace

Expand All @@ -418,7 +418,7 @@ Lists all the duplicates in the workspace
Prints help information


# cargo hackerman tree
## cargo hackerman tree

Make a tree out of dependencies

Expand Down Expand Up @@ -461,7 +461,7 @@ Examples:
cargo hackerman tree serde_json preserve_order
```

# cargo hackerman show
## cargo hackerman show

Show crate manifest, readme, repository or documentation

Expand Down
23 changes: 12 additions & 11 deletions src/feat_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ impl<'a> Eq for Pid<'a> {}

impl<'a> PartialOrd for Pid<'a> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.0.partial_cmp(&other.0)
Some(self.cmp(other))
}
}

Expand Down Expand Up @@ -753,6 +753,17 @@ impl<'a> From<&'a str> for FeatTarget<'a> {
}
}

impl Fid<'_> {
#[must_use]
/// Create a base feature from possibly named one
pub const fn get_base(&self) -> Self {
Self {
dep: Feat::Base,
..*self
}
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down Expand Up @@ -829,13 +840,3 @@ mod test {
})
}
}
impl Fid<'_> {
#[must_use]
/// Create a base feature from possibly named one
pub const fn get_base(&self) -> Self {
Self {
dep: Feat::Base,
..*self
}
}
}
7 changes: 5 additions & 2 deletions src/hack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ fn show_detached_dep_tree(tree: &DetachedDepTree, fg: &FeatGraph) -> &'static st
pub enum Collect<'a> {
/// all targets, normal and builds
AllTargets,
/// all targets, normal dependencies only
NormalOnly,
/// current target only
Target,
/// current target only, normal and build dependencies globally, dev dependencies for workspace
Expand Down Expand Up @@ -149,14 +151,15 @@ fn collect_features_from<M>(
Collect::Target | Collect::NoDev | Collect::DevTarget | Collect::MemberDev(_) => e
.weight()
.satisfies(fg.features[e.source()], filter, &fg.platforms, &fg.cfgs),
Collect::NormalOnly => e.weight().is_normal(),
}
});

loop {
while let Some(ix) = dfs.next(&g) {
if let Some(fid) = fg.features[ix].fid() {
if let Some(parent) = fg.fid_cache.get(&fid.get_base()) {
to.entry(*parent).or_insert_with(BTreeSet::new).insert(ix);
to.entry(*parent).or_default().insert(ix);
}
}
}
Expand Down Expand Up @@ -223,7 +226,7 @@ pub fn get_changeset<'a>(fg: &mut FeatGraph<'a>, no_dev: bool) -> anyhow::Result
&mut Dfs::new(&fg.features, fg.root),
fg,
&mut raw_workspace_feats,
Collect::AllTargets,
Collect::NormalOnly,
);

// For reasons unknown cargo resolves dependencies for all the targets including those
Expand Down
2 changes: 1 addition & 1 deletion src/mergetool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn merge(base: &Path, local: &Path, remote: &Path, _merged: &Path) -> anyhow
let merged_bytes = output.stdout;
let code = output.status;

std::fs::write(local, &merged_bytes)?;
std::fs::write(local, merged_bytes)?;

std::process::exit(code.code().unwrap_or(-1));
}
7 changes: 6 additions & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ impl DepKindInfo {
) -> bool {
if self.kind == DependencyKind::Development {
match filter {
Collect::AllTargets | Collect::Target | Collect::NoDev => return false,
Collect::AllTargets | Collect::Target | Collect::NoDev | Collect::NormalOnly => {
return false
}
Collect::MemberDev(pid) => {
if let Some(this_fid) = source.fid() {
{
Expand Down Expand Up @@ -110,6 +112,9 @@ impl Link {
.iter()
.all(|k| k.kind == DependencyKind::Development)
}
pub(crate) fn is_normal(&self) -> bool {
self.kinds.iter().any(|k| k.kind == DependencyKind::Normal)
}

pub(crate) fn satisfies(
&self,
Expand Down