Skip to content

Commit

Permalink
revert test and lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hallettj committed Jan 27, 2025
1 parent 327d31e commit cb38ed3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
9 changes: 8 additions & 1 deletion crate2nix/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,14 @@ impl Display for Source {
sha256,
registry,
..
} => write!(f, "{} {} from {}: {}", name, version, registry, sha256),
} => write!(
f,
"{} {} from {}: {}",
name,
version,
registry.to_string(),
sha256
),
Source::Git { url, rev, sha256 } => write!(f, "{}#{} via git: {}", url, rev, sha256),
Source::Nix { file, attr: None } => write!(f, "{}", file),
Source::Nix {
Expand Down
2 changes: 1 addition & 1 deletion crate2nix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn prefetch_and_fill_registries(
config: &GenerateConfig,
default_nix: &mut BuildInfo,
) -> Result<(), Error> {
default_nix.registries = prefetch::prefetch_registries(config, &default_nix.crates)
default_nix.registries = prefetch::prefetch_registries(config, &mut default_nix.crates)
.map_err(|e| format_err!("while prefetching crates for calculating sha256: {}", e))?;

Ok(())
Expand Down
9 changes: 7 additions & 2 deletions crate2nix/src/prefetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ pub fn prefetch(
let (sha256, hash_source) = if let Some(HashWithSource { sha256, source }) = hash {
(sha256.trim().to_string(), source)
} else {
eprintln!("Prefetching {:>4}/{}: {}", idx, without_hash_num, source);
eprintln!(
"Prefetching {:>4}/{}: {}",
idx,
without_hash_num,
source.to_string()
);
idx += 1;
(source.prefetch()?, HashSource::Prefetched)
};
Expand Down Expand Up @@ -197,7 +202,7 @@ pub fn prefetch_registries(
&[&format!(
"{}{}config.json",
e.key(),
if e.key().ends_with('/') { "" } else { "/" }
if e.key().ends_with("/") { "" } else { "/" }
)],
)?;
e.insert(out);
Expand Down
14 changes: 7 additions & 7 deletions crate2nix/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,14 +633,14 @@ impl ResolvedSource {
}
}

impl Display for ResolvedSource {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl ToString for ResolvedSource {
fn to_string(&self) -> String {
match self {
Self::CratesIo(source) => write!(f, "{}", source),
Self::Registry(source) => write!(f, "{}", source),
Self::Git(source) => write!(f, "{}", source),
Self::LocalDirectory(source) => write!(f, "{}", source),
Self::Nix(source) => write!(f, "{}", source),
Self::CratesIo(source) => source.to_string(),
Self::Registry(source) => source.to_string(),
Self::Git(source) => source.to_string(),
Self::LocalDirectory(source) => source.to_string(),
Self::Nix(source) => source.to_string(),
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions crate2nix/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
//! Constructor functions for test data.
#![allow(missing_docs)]

///! Constructor functions for test data.
use cargo_metadata::{Dependency, Metadata, Node, NodeDep, Package, PackageId, Resolve};
use std::path::PathBuf;
use tempdir::TempDir;
Expand All @@ -11,7 +8,6 @@ pub fn generate_config() -> crate::GenerateConfig {
crate::GenerateConfig {
cargo_toml: vec!["Cargo.toml".into()],
crate_hashes_json: "crate-hashes.json".into(),
registry_hashes_json: "registry-hashes.json".into(),
nixpkgs_path: "bogus-nixpkgs-path".into(),
other_metadata_options: vec![],
output: "Cargo.nix".into(),
Expand Down
4 changes: 0 additions & 4 deletions crate2nix/tests/self_build_up_to_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ fn self_up_to_date() {
output: PathBuf::from("./Cargo.nix"),
nixpkgs_path: "../nix/nixpkgs.nix".to_string(),
crate_hashes_json: PathBuf::from("./crate-hashes.json"),
registry_hashes_json: PathBuf::from("./registry-hashes.json"),
other_metadata_options: vec![],
use_cargo_lock_checksums: true,
read_crate_hashes: true,
Expand Down Expand Up @@ -77,9 +76,6 @@ fn assert_up_to_date(project_dir: &Path) {
crate_hashes_json: PathBuf::from("../")
.join(project_dir)
.join("./crate-hashes.json"),
registry_hashes_json: PathBuf::from("../")
.join(project_dir)
.join("./registry-hashes.json"),
other_metadata_options: vec![],
use_cargo_lock_checksums: true,
read_crate_hashes: true,
Expand Down

0 comments on commit cb38ed3

Please sign in to comment.