Skip to content

Commit

Permalink
Merge pull request #96 from smoelius/xdg
Browse files Browse the repository at this point in the history
Use `xdg` instead of `directories-next`; correct typo in directory name
  • Loading branch information
Shnatsel authored Mar 22, 2024
2 parents 46a45a5 + 3a8def9 commit ede428b
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 81 deletions.
77 changes: 7 additions & 70 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ authors = ["Andreas Molzer <[email protected]>", "Sergey \"Shnatsel\" Davido
edition = "2018"
license = "Apache-2.0 OR MIT OR Zlib"
categories = ["development-tools::cargo-plugins", "command-line-utilities"]
exclude = ["dep_tests/"]
exclude = ["deps_tests/"]

[dependencies]
cargo_metadata = "0.15.0"
csv = "1.1"
directories-next = "2"
flate2 = "1"
humantime = "2"
humantime-serde = "1"
Expand All @@ -23,6 +22,7 @@ tar = "0.4.30"
indicatif = "0.17.0"
bpaf = { version = "0.9.1", features = ["derive", "dull-color"] }
anyhow = "1.0.28"
xdg = "2.5"

[dev-dependencies]
schemars = "0.8.3"
2 changes: 1 addition & 1 deletion dep_tests/README.md → deps_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Each of the `.metadata.json` files was generated with a command of the following
cargo metadata |
sed "s,${PWD},\$CARGO_MANIFEST_DIR,g" |
sed "s,${HOME},\$HOME,g" |
jq --sort-keys > ${CARGO_SUPPLY_CHAIN_DIR}/dep_tests/${PACKAGE}_${VERSION}.metadata.json
jq --sort-keys > ${CARGO_SUPPLY_CHAIN_DIR}/deps_tests/${PACKAGE}_${VERSION}.metadata.json
```

The other files were then generated with the following command:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 9 additions & 5 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,15 @@ mod tests {

#[test]
fn deps() {
for entry in read_dir("dep_tests").unwrap() {
for entry in read_dir("deps_tests").unwrap() {
let entry = entry.unwrap();
let path = entry.path();

let Some(prefix) = path.to_string_lossy().strip_suffix(".metadata.json").map(ToOwned::to_owned) else {
let Some(prefix) = path
.to_string_lossy()
.strip_suffix(".metadata.json")
.map(ToOwned::to_owned)
else {
continue;
};

Expand Down Expand Up @@ -281,23 +285,23 @@ mod tests {

#[test]
fn cargo() {
let deps = sourced_dependencies_from_file("dep_tests/cargo_0.70.1.deps.json");
let deps = sourced_dependencies_from_file("deps_tests/cargo_0.70.1.deps.json");

assert!(deps.iter().any(|dep| dep.package.name == "snapbox"));
assert!(deps.iter().any(|dep| dep.package.name == "snapbox-macros"));
}

#[test]
fn cargo_no_dev() {
let deps = sourced_dependencies_from_file("dep_tests/cargo_0.70.1.deps_no_dev.json");
let deps = sourced_dependencies_from_file("deps_tests/cargo_0.70.1.deps_no_dev.json");

assert!(deps.iter().all(|dep| dep.package.name != "snapbox"));
assert!(deps.iter().all(|dep| dep.package.name != "snapbox-macros"));
}

#[test]
fn snapbox() {
let deps = sourced_dependencies_from_file("dep_tests/snapbox_0.4.11.deps.json");
let deps = sourced_dependencies_from_file("deps_tests/snapbox_0.4.11.deps.json");

assert!(deps.iter().any(|dep| dep.package.name == "snapbox-macros"));
}
Expand Down
6 changes: 3 additions & 3 deletions src/crates_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ impl CratesCache {
}

fn cache_dir() -> Option<PathBuf> {
let projects =
directories_next::ProjectDirs::from("", "rust-secure-code", "cargo-supply-chain")?;
Some(projects.cache_dir().to_owned())
xdg::BaseDirectories::with_prefix("cargo-supply-chain")
.ok()
.map(|base_directories| base_directories.get_cache_home())
}

/// Re-download the list from the data dumps.
Expand Down

0 comments on commit ede428b

Please sign in to comment.