8000 cargo fmt by figsoda · Pull Request #655 · nix-community/nix-init · GitHub
[go: up one dir, main page]

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
1,765 changes: 1,162 additions & 603 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = ["license-store-cache"]
[workspace.package]
version = "0.3.2"
authors = ["figsoda <figsoda@pm.me>"]
edition = "2021"
edition = "2024"
license = "MPL-2.0"

[workspace.dependencies]
Expand All @@ -28,7 +28,7 @@ include = ["data", "src", "Cargo.lock", "Cargo.toml", "build.rs"]
anyhow = "1.0.95"
askalono.workspace = true
bstr = "1.10.0"
cargo = { git = "https://github.com/rust-lang/cargo.git", rev = "d585829270c758468b9fd20b2b7fd3d4f4557763" }
cargo = "0.93.0"
chumsky = "=1.0.0-alpha.6"
expand = "0.3.0"
flate2 = "1.0.34"
Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::{
env,
fs::{create_dir_all, File},
fs::{File, create_dir_all},
path::Path,
};

use clap::{CommandFactory, ValueEnum};
use clap_complete::{generate_to, Shell};
use clap_complete::{Shell, generate_to};
use clap_mangen::Man;

include!("src/cli.rs");
Expand Down
1 change: 0 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ rustPlatform.buildRustPackage rec {
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes."cargo-0.82.0" = "sha256-1G14vLW3FhLxOWGxuHXcWgb+XXS1vOOyQYKVbrJWlmI=";
};

nativeBuildInputs = [
8000 Expand Down
34 changes: 28 additions & 6 deletions flake.lock

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

18 changes: 18 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
Expand Down Expand Up @@ -33,6 +38,19 @@
...
}:
{
devShells.default = pkgs.mkShell {
env = {
NIX_INIT_LOG = "nix_init=trace";
RUST_BACKTRACE = true;
};

shellHook = ''
mkdir -p data
ln -sf ${config.packages.get-nix-license} data/get_nix_license.rs
ln -sf ${config.packages.license-store-cache} data/license-store-cache.zstd
'';
};

packages.nix-init = pkgs.callPackage ./default.nix {
inherit (config.packages) get-nix-license license-store-cache;
};
Expand Down
27 changes: 15 additions & 12 deletions formatters.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
imports = [ inputs.treefmt-nix.flakeModule ];

perSystem =
{ pkgs, ... }:
{ inputs', pkgs, ... }:
{
treefmt = {
# Used to find the project root
Expand All @@ -17,17 +17,20 @@
deadnix.enable = true;
actionlint.enable = true;
};
settings.global.excludes = [
"*.toml"
"*.snap"
"*/go.mod"
"*/go.sum"
"*.go"
".github/dependabot.yml"
".mergify.yml"
"assets/*"
"LICENSE"
];
settings = {
formatter.rustfmt.command = "${inputs'.fenix.packages.latest.rustfmt}/bin/rustfmt";
global.excludes = [
"*.toml"
"*.snap"
"*/go.mod"
"*/go.sum"
"*.go"
".github/dependabot.yml"
".mergify.yml"
"assets/*"
"LICENSE"
];
};
};
};
}
1 change: 0 additions & 1 deletion license-store-cache.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ rustPlatform.buildRustPackage {

cargoLock = {
lockFile = ./Cargo.lock;
outputHashes."cargo-0.82.0" = "sha256-1G14vLW3FhLxOWGxuHXcWgb+XXS1vOOyQYKVbrJWlmI=";
};

buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
Expand Down
2 changes: 1 addition & 1 deletion src/cfg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{fs, path::PathBuf};

use anyhow::{Context, Result};
use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION};
use reqwest::header::{AUTHORIZATION, HeaderMap, HeaderValue};
use rustc_hash::FxHashMap;
use secrecy::{ExposeSecret, SecretString};
use serde::Deserialize;
Expand Down
2 changes: 1 addition & 1 deletion src/fetcher/crates_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::Deserialize;
use tracing::error;

use crate::{
fetcher::{json, PackageInfo, Revisions, Version},
fetcher::{PackageInfo, Revisions, Version, json},
license::parse_spdx_expression,
};

Expand Down
8 changes: 4 additions & 4 deletions src/fetcher/gitea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_hash::FxHashMap;
use rustyline::completion::Pair;
use serde::Deserialize;

use crate::fetcher::{json, success, PackageInfo, Revisions, Version};
use crate::fetcher::{PackageInfo, Revisions, Version, json, success};

#[derive(Deserialize)]
struct Repo {
Expand Down Expand Up @@ -96,7 +96,7 @@ pub async fn get_package_info(cl: &Client, domain: &str, owner: &str, repo: &str
latest = sha.clone();
}

let date = &commit.committer.date[0..10];
let date = &commit.committer.date[0 .. 10];
let msg = commit.message.lines().next().unwrap_or_default();

completions.push(Pair {
Expand All @@ -113,7 +113,7 @@ pub async fn get_package_info(cl: &Client, domain: &str, owner: &str, repo: &str
}

for Commit { sha, commit } in commits {
let date = &commit.committer.date[0..10];
let date = &commit.committer.date[0 .. 10];
let msg = commit.message.lines().next().unwrap_or_default();
completions.push(Pair {
display: format!("{sha} ({date}) {msg}"),
Expand Down Expand Up @@ -158,7 +158,7 @@ pub async fn get_version(

Some(if sha.starts_with(rev) {
Version::Commit {
date: commit.committer.date[0..10].into(),
date: commit.committer.date[0 .. 10].into(),
msg: "".into(),
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/fetcher/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_hash::FxHashMap;
use rustyline::completion::Pair;
use serde::Deserialize;

use crate::fetcher::{json, success, PackageInfo, Revisions, Version};
use crate::fetcher::{PackageInfo, Revisions, Version, json, success};

#[derive(Deserialize)]
struct Repo {
Expand Down Expand Up @@ -115,7 +115,7 @@ pub async fn get_package_info(
latest = sha.clone();
}

let date = &commit.committer.date[0..10];
let date = &commit.committer.date[0 .. 10];
let msg = commit.message.lines().next().unwrap_or_default();

completions.push(Pair {
Expand All @@ -132,7 +132,7 @@ pub async fn get_package_info(
}

for Commit { sha, commit } in commits {
let date = &commit.committer.date[0..10];
let date = &commit.committer.date[0 .. 10];
let msg = commit.message.lines().next().unwrap_or_default();
completions.push(Pair {
display: format!("{sha} ({date}) {msg}"),
Expand Down Expand Up @@ -179,7 +179,7 @@ pub async fn get_version(

Some(if sha.starts_with(rev) {
Version::Commit {
date: commit.committer.date[0..10].into(),
date: commit.committer.date[0 .. 10].into(),
msg: "".into(),
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/fetcher/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use rustyline::completion::Pair;
use serde::Deserialize;

use crate::{
fetcher::{json, success, PackageInfo, Version},
Revisions,
fetcher::{PackageInfo, Version, json, success},
};

#[derive(Deserialize)]
Expand Down Expand Up @@ -101,7 +101,7 @@ pub async fn get_package_info(
latest = id.clone();
}

let date = &committed_date[0..10];
let date = &committed_date[0 .. 10];

completions.push(Pair {
display: format!("{id} ({date} - HEAD) {title}"),
Expand All @@ -122,7 +122,7 @@ pub async fn get_package_info(
title,
} in commits
{
let date = &committed_date[0..10];
let date = &committed_date[0 .. 10];
completions.push(Pair {
display: format!("{id} ({date}) {title}"),
replacement: id.clone(),
Expand Down Expand Up @@ -174,7 +174,7 @@ pub async fn get_version(

Some(if id.starts_with(rev) {
Version::Commit {
date: committed_date[0..10].into(),
date: committed_date[0 .. 10].into(),
msg: "".into(),
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod pypi;

use anyhow::Result;
use parse_display::Display;
use reqwest::{header::HeaderMap, Client, IntoUrl};
use reqwest::{Client, IntoUrl, header::HeaderMap};
use rustc_hash::FxHashMap;
use rustyline::completion::Pair;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -143,7 +143,7 @@ impl Fetcher {
owner,
repo,
} => gitea::get_package_info(cl, domain, owner, repo).await,
Fetcher::FetchPypi { ref mut pname } => pypi::get_package_info(cl, pname).await,
Fetcher::FetchPypi { pname } => pypi::get_package_info(cl, pname).await,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/fetcher/pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use itertools::Itertools;
use reqwest::Client;
use rustyline::completion::Pair;
use serde::Deserialize;
use serde_with::{serde_as, DefaultOnNull, Map};
use serde_with::{DefaultOnNull, Map, serde_as};
use time::OffsetDateTime;
use tracing::error;

use crate::{
fetcher::{json, PackageInfo, PypiFormat, Revisions, Version},
fetcher::{PackageInfo, PypiFormat, Revisions, Version, json},
lang::python::get_python_dependencies,
license::parse_spdx_expression,
};
Expand Down Expand Up @@ -129,7 +129,7 @@ fn get_pname<'a>(release: &'a Release, version: &str, ext: &'static str) -> Opti
mod tests {
use time::OffsetDateTime;

use super::{get_pname, Release};
use super::{Release, get_pname};

#[test]
fn basic() {
Expand Down
2 changes: 1 addition & 1 deletion src/lang/go/goreleaser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Result;
use heck::ToLowerCamelCase;
use regex::{Captures, Regex};
use serde::Deserialize;
use serde_with::{serde_as, OneOrMany};
use serde_with::{OneOrMany, serde_as};

use crate::utils::ResultExt;

Expand Down
2 changes: 1 addition & 1 deletion src/lang/go/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod tests {

use crate::{
inputs::AllInputs,
lang::go::{load_go_dependencies, GoPackage},
lang::go::{GoPackage, load_go_dependencies},
};

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/lang/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use std::{
path::{Path, PathBuf},
};

use chumsky::{error::EmptyErr, extra::Err, primitive::end, Parser};
use chumsky::{Parser, error::EmptyErr, extra::Err, primitive::end};
use heck::{AsKebabCase, ToKebabCase};
use pep_508::{Comparator, Dependency, Marker, Operator, Variable};
use serde::Deserialize;
use serde_with::{serde_as, DefaultOnError};
use serde_with::{DefaultOnError, serde_as};

use crate::{inputs::AllInputs, license::parse_spdx_expression, utils::ResultExt};

Expand Down
Loading
0