8000 small readability clean up by figsoda · Pull Request #667 · nix-community/nix-init · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
47 changes: 23 additions & 24 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,13 @@ async fn run() -> Result<()> {

let src_expr = match fetcher {
MaybeFetcher::Known(Fetcher::FetchCrate { pname: ref name }) => {
let hash = String::from_utf8(cmd.arg(&url).arg(&rev).arg("-H").get_stdout().await?)
let hash: String = cmd
.arg(&url)
.arg(&rev)
.arg("-H")
.get_stdout()
.await?
.try_into()
.context("failed to parse nurl output")?;

if &pname == name {
Expand Down Expand Up @@ -253,28 +259,22 @@ async fn run() -> Result<()> {
cmd.arg("-A").arg("extension").arg(pypi_format.to_string());
}

if &pname == name {
let hash = String::from_utf8(
cmd.arg(format!("https://pypi.org/project/{name}"))
.arg(&rev)
.get_stdout()
.await?,
)
let hash: String = cmd
.arg(format!("https://pypi.org/project/{name}"))
.arg(&rev)
.get_stdout()
.await?
.try_into()
.context("failed to parse nurl output")?;

if &pname == name {
formatdoc! {r#"
fetchPypi {{
inherit (finalAttrs) pname version;
hash = "{hash}";{ext}
}}"#,
}
} else {
let hash = String::from_utf8(
cmd.arg(format!("https://pypi.org/project/{name}"))
.arg(&rev)
.get_stdout()
.await?,
)
.context("failed to parse nurl output")?;
formatdoc! {r#"
fetchPypi {{
pname = {name:?};
Expand All @@ -294,15 +294,14 @@ async fn run() -> Result<()> {
.arg(rev.replacen(&version, "${finalAttrs.version}", 1));
}

String::from_utf8(
cmd.arg(&url)
.arg(&rev)
.arg("-i")
.arg("2")
.get_stdout()
.await?,
)
.context("failed to parse nurl output")?
cmd.arg(&url)
.arg(&rev)
.arg("-i")
.arg("2")
.get_stdout()
.await?
.try_into()
.context("failed to parse nurl output")?
}
};

Expand Down
0