mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-22 00:51:11 -05:00
commit
ec8713ae84
16 changed files with 72 additions and 50 deletions
|
@ -1 +1 @@
|
|||
msrv = "1.60.0" # MSRV
|
||||
msrv = "1.64.0" # MSRV
|
||||
|
|
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -51,7 +51,7 @@ jobs:
|
|||
- name: No-default features
|
||||
run: cargo test --workspace --no-default-features
|
||||
msrv:
|
||||
name: "Check MSRV: 1.60.0"
|
||||
name: "Check MSRV: 1.64.0"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
@ -59,7 +59,7 @@ jobs:
|
|||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.60.0 # MSRV
|
||||
toolchain: 1.64.0 # MSRV
|
||||
profile: minimal
|
||||
override: true
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
@ -113,7 +113,7 @@ jobs:
|
|||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.60.0 # MSRV
|
||||
toolchain: 1.64.0 # MSRV
|
||||
profile: minimal
|
||||
override: true
|
||||
components: clippy
|
||||
|
|
4
.github/workflows/rust-next.yml
vendored
4
.github/workflows/rust-next.yml
vendored
|
@ -59,9 +59,9 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- 1.60.0 # MSRV
|
||||
- 1.64.0 # MSRV
|
||||
- stable
|
||||
continue-on-error: ${{ matrix.rust != '1.60.0' }} # MSRV
|
||||
continue-on-error: ${{ matrix.rust != '1.64.0' }} # MSRV
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
|
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1121,9 +1121,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-exit"
|
||||
version = "1.0.3"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0da6bbc8ef87314d4f596ad9d02db375c3f2d77fba91067a6f6a5754fdc8cb49"
|
||||
checksum = "d2d778539881515d37cd91925d169f4a351120c5a1b44fce2b7c462b0d7f4ec6"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
|
|
|
@ -14,7 +14,7 @@ readme = "README.md"
|
|||
categories = ["development-tools", "text-processing"]
|
||||
keywords = ["development", "spelling"]
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
include = [
|
||||
"src/**/*",
|
||||
"Cargo.toml",
|
||||
|
@ -73,7 +73,7 @@ bstr = "1.0"
|
|||
once_cell = "1.15.0"
|
||||
ahash = "0.8"
|
||||
difflib = "0.4"
|
||||
proc-exit = "1.0"
|
||||
proc-exit = "2.0"
|
||||
human-panic = "1.0.3"
|
||||
content_inspector = "0.2.4"
|
||||
unicode-segmentation = "1.10.0"
|
||||
|
|
|
@ -9,7 +9,7 @@ categories = ["development-tools", "text-processing"]
|
|||
keywords = ["development", "spelling"]
|
||||
license = "CC-BY-SA-3.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
publish = false
|
||||
include = [
|
||||
"src/**/*",
|
||||
|
|
|
@ -7,7 +7,7 @@ categories = ["development-tools", "text-processing"]
|
|||
keywords = ["development", "spelling", "no_std"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
include = [
|
||||
"src/**/*",
|
||||
"Cargo.toml",
|
||||
|
|
|
@ -28,9 +28,9 @@ impl<V> DictTrie<V> {
|
|||
match child.children {
|
||||
DictTrieChild::Nested(n) => {
|
||||
let byte = bytes[i];
|
||||
let index = if (b'a'..b'z').contains(&byte) {
|
||||
let index = if (b'a'..=b'z').contains(&byte) {
|
||||
byte - b'a'
|
||||
} else if (b'A'..b'Z').contains(&byte) {
|
||||
} else if (b'A'..=b'Z').contains(&byte) {
|
||||
byte - b'A'
|
||||
} else {
|
||||
return self.unicode.find(word);
|
||||
|
|
|
@ -9,7 +9,7 @@ categories = ["development-tools", "text-processing"]
|
|||
keywords = ["development", "spelling"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
publish = false
|
||||
include = [
|
||||
"src/**/*",
|
||||
|
|
|
@ -9,7 +9,7 @@ readme = "../../README.md"
|
|||
categories = ["development-tools", "text-processing"]
|
||||
keywords = ["development", "spelling"]
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
include = [
|
||||
"src/**/*",
|
||||
"Cargo.toml",
|
||||
|
|
|
@ -9,7 +9,7 @@ readme = "../../README.md"
|
|||
categories = ["development-tools", "text-processing"]
|
||||
keywords = ["development", "spelling"]
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
include = [
|
||||
"src/**/*",
|
||||
"Cargo.toml",
|
||||
|
|
|
@ -9,7 +9,7 @@ readme = "../../README.md"
|
|||
categories = ["development-tools", "text-processing"]
|
||||
keywords = ["development", "spelling"]
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
include = [
|
||||
"src/**/*",
|
||||
"Cargo.toml",
|
||||
|
|
|
@ -8,7 +8,7 @@ repository = "https://github.com/crate-ci/typos"
|
|||
readme = "../../README.md"
|
||||
categories = ["text-processing"]
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
include = [
|
||||
"src/**/*",
|
||||
"Cargo.toml",
|
||||
|
|
|
@ -9,7 +9,7 @@ readme = "../../README.md"
|
|||
categories = ["development-tools", "text-processing"]
|
||||
keywords = ["development", "spelling"]
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
include = [
|
||||
"src/**/*",
|
||||
"Cargo.toml",
|
||||
|
|
|
@ -9,7 +9,7 @@ readme = "README.md"
|
|||
categories = ["development-tools", "text-processing"]
|
||||
keywords = ["development", "spelling"]
|
||||
edition = "2021"
|
||||
rust-version = "1.60.0" # MSRV
|
||||
rust-version = "1.64.0" # MSRV
|
||||
publish = false
|
||||
include = [
|
||||
"src/**/*",
|
||||
|
|
|
@ -5,7 +5,7 @@ use clap::Parser;
|
|||
mod args;
|
||||
mod report;
|
||||
|
||||
use proc_exit::WithCodeResultExt;
|
||||
use proc_exit::prelude::*;
|
||||
|
||||
fn main() {
|
||||
human_panic::setup_panic!();
|
||||
|
@ -19,7 +19,7 @@ fn run() -> proc_exit::ExitResult {
|
|||
Ok(args) => args,
|
||||
Err(e) if e.use_stderr() => {
|
||||
let _ = e.print();
|
||||
return proc_exit::Code::USAGE_ERR.ok();
|
||||
return proc_exit::sysexits::USAGE_ERR.ok();
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = e.print();
|
||||
|
@ -52,19 +52,24 @@ fn run() -> proc_exit::ExitResult {
|
|||
}
|
||||
|
||||
fn run_dump_config(args: &args::Args, output_path: &std::path::Path) -> proc_exit::ExitResult {
|
||||
let global_cwd = std::env::current_dir()?;
|
||||
let global_cwd = std::env::current_dir().to_sysexits()?;
|
||||
|
||||
let path = &args.path[0];
|
||||
let cwd = if path == std::path::Path::new("-") {
|
||||
global_cwd
|
||||
} else if path.is_file() {
|
||||
let mut cwd = path.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?;
|
||||
let mut cwd = path
|
||||
.canonicalize()
|
||||
.with_code(proc_exit::sysexits::USAGE_ERR)?;
|
||||
cwd.pop();
|
||||
cwd
|
||||
} else {
|
||||
path.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?
|
||||
path.canonicalize()
|
||||
.with_code(proc_exit::sysexits::USAGE_ERR)?
|
||||
};
|
||||
let cwd = cwd.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?;
|
||||
let cwd = cwd
|
||||
.canonicalize()
|
||||
.with_code(proc_exit::sysexits::USAGE_ERR)?;
|
||||
|
||||
let storage = typos_cli::policy::ConfigStorage::new();
|
||||
let mut engine = typos_cli::policy::ConfigEngine::new(&storage);
|
||||
|
@ -72,8 +77,8 @@ fn run_dump_config(args: &args::Args, output_path: &std::path::Path) -> proc_exi
|
|||
|
||||
let mut overrides = typos_cli::config::Config::default();
|
||||
if let Some(path) = args.custom_config.as_ref() {
|
||||
let custom =
|
||||
typos_cli::config::Config::from_file(path).with_code(proc_exit::Code::CONFIG_ERR)?;
|
||||
let custom = typos_cli::config::Config::from_file(path)
|
||||
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
||||
overrides.update(&custom);
|
||||
}
|
||||
overrides.update(&args.config.to_config());
|
||||
|
@ -81,35 +86,42 @@ fn run_dump_config(args: &args::Args, output_path: &std::path::Path) -> proc_exi
|
|||
|
||||
let config = engine
|
||||
.load_config(&cwd)
|
||||
.with_code(proc_exit::Code::CONFIG_ERR)?;
|
||||
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
||||
|
||||
let mut defaulted_config = typos_cli::config::Config::from_defaults();
|
||||
defaulted_config.update(&config);
|
||||
let output =
|
||||
toml_edit::easy::to_string_pretty(&defaulted_config).with_code(proc_exit::Code::FAILURE)?;
|
||||
if output_path == std::path::Path::new("-") {
|
||||
std::io::stdout().write_all(output.as_bytes())?;
|
||||
std::io::stdout()
|
||||
.write_all(output.as_bytes())
|
||||
.to_sysexits()?;
|
||||
} else {
|
||||
std::fs::write(output_path, &output)?;
|
||||
std::fs::write(output_path, &output).to_sysexits()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_type_list(args: &args::Args) -> proc_exit::ExitResult {
|
||||
let global_cwd = std::env::current_dir()?;
|
||||
let global_cwd = std::env::current_dir().to_sysexits()?;
|
||||
|
||||
let path = &args.path[0];
|
||||
let cwd = if path == std::path::Path::new("-") {
|
||||
global_cwd
|
||||
} else if path.is_file() {
|
||||
let mut cwd = path.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?;
|
||||
let mut cwd = path
|
||||
.canonicalize()
|
||||
.with_code(proc_exit::sysexits::USAGE_ERR)?;
|
||||
cwd.pop();
|
||||
cwd
|
||||
} else {
|
||||
path.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?
|
||||
path.canonicalize()
|
||||
.with_code(proc_exit::sysexits::USAGE_ERR)?
|
||||
};
|
||||
let cwd = cwd.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?;
|
||||
let cwd = cwd
|
||||
.canonicalize()
|
||||
.with_code(proc_exit::sysexits::USAGE_ERR)?;
|
||||
|
||||
let storage = typos_cli::policy::ConfigStorage::new();
|
||||
let mut engine = typos_cli::policy::ConfigEngine::new(&storage);
|
||||
|
@ -117,8 +129,8 @@ fn run_type_list(args: &args::Args) -> proc_exit::ExitResult {
|
|||
|
||||
let mut overrides = typos_cli::config::Config::default();
|
||||
if let Some(path) = args.custom_config.as_ref() {
|
||||
let custom =
|
||||
typos_cli::config::Config::from_file(path).with_code(proc_exit::Code::CONFIG_ERR)?;
|
||||
let custom = typos_cli::config::Config::from_file(path)
|
||||
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
||||
overrides.update(&custom);
|
||||
}
|
||||
overrides.update(&args.config.to_config());
|
||||
|
@ -126,13 +138,13 @@ fn run_type_list(args: &args::Args) -> proc_exit::ExitResult {
|
|||
|
||||
engine
|
||||
.init_dir(&cwd)
|
||||
.with_code(proc_exit::Code::CONFIG_ERR)?;
|
||||
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
||||
let definitions = engine.file_types(&cwd);
|
||||
|
||||
let stdout = std::io::stdout();
|
||||
let mut handle = stdout.lock();
|
||||
for (name, globs) in definitions {
|
||||
writeln!(handle, "{}: {}", name, itertools::join(globs, ", "))?;
|
||||
writeln!(handle, "{}: {}", name, itertools::join(globs, ", ")).to_sysexits()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -143,7 +155,7 @@ fn run_checks(
|
|||
stdout_palette: report::Palette,
|
||||
stderr_palette: report::Palette,
|
||||
) -> proc_exit::ExitResult {
|
||||
let global_cwd = std::env::current_dir()?;
|
||||
let global_cwd = std::env::current_dir().to_sysexits()?;
|
||||
|
||||
let storage = typos_cli::policy::ConfigStorage::new();
|
||||
let mut engine = typos_cli::policy::ConfigEngine::new(&storage);
|
||||
|
@ -151,8 +163,8 @@ fn run_checks(
|
|||
|
||||
let mut overrides = typos_cli::config::Config::default();
|
||||
if let Some(path) = args.custom_config.as_ref() {
|
||||
let custom =
|
||||
typos_cli::config::Config::from_file(path).with_code(proc_exit::Code::CONFIG_ERR)?;
|
||||
let custom = typos_cli::config::Config::from_file(path)
|
||||
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
||||
overrides.update(&custom);
|
||||
}
|
||||
overrides.update(&args.config.to_config());
|
||||
|
@ -164,16 +176,19 @@ fn run_checks(
|
|||
let cwd = if path == std::path::Path::new("-") {
|
||||
global_cwd.clone()
|
||||
} else if path.is_file() {
|
||||
let mut cwd = path.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?;
|
||||
let mut cwd = path
|
||||
.canonicalize()
|
||||
.with_code(proc_exit::sysexits::USAGE_ERR)?;
|
||||
cwd.pop();
|
||||
cwd
|
||||
} else {
|
||||
path.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?
|
||||
path.canonicalize()
|
||||
.with_code(proc_exit::sysexits::USAGE_ERR)?
|
||||
};
|
||||
|
||||
engine
|
||||
.init_dir(&cwd)
|
||||
.with_code(proc_exit::Code::CONFIG_ERR)?;
|
||||
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
||||
let walk_policy = engine.walk(&cwd);
|
||||
|
||||
let threads = if path.is_file() { 1 } else { args.threads };
|
||||
|
@ -193,9 +208,11 @@ fn run_checks(
|
|||
for pattern in walk_policy.extend_exclude.iter() {
|
||||
overrides
|
||||
.add(&format!("!{}", pattern))
|
||||
.with_code(proc_exit::Code::CONFIG_ERR)?;
|
||||
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
||||
}
|
||||
let overrides = overrides.build().with_code(proc_exit::Code::CONFIG_ERR)?;
|
||||
let overrides = overrides
|
||||
.build()
|
||||
.with_code(proc_exit::sysexits::CONFIG_ERR)?;
|
||||
walk.overrides(overrides);
|
||||
}
|
||||
|
||||
|
@ -234,7 +251,12 @@ fn run_checks(
|
|||
}
|
||||
.map_err(|e| {
|
||||
e.io_error()
|
||||
.map(|i| proc_exit::Code::from(i.kind()))
|
||||
.map(|i| {
|
||||
let kind = i.kind();
|
||||
proc_exit::sysexits::io_to_sysexists(kind)
|
||||
.or_else(|| proc_exit::bash::io_to_signal(kind))
|
||||
.unwrap_or(proc_exit::sysexits::IO_ERR)
|
||||
})
|
||||
.unwrap_or_default()
|
||||
.with_message(e)
|
||||
})?;
|
||||
|
@ -253,7 +275,7 @@ fn run_checks(
|
|||
// `Failure` from something else and get it mixed up with typos.
|
||||
//
|
||||
// Can't use DataErr or anything else an std::io::ErrorKind might map to.
|
||||
proc_exit::Code::UNKNOWN.ok()
|
||||
proc_exit::Code::new(2).ok()
|
||||
} else {
|
||||
proc_exit::Code::SUCCESS.ok()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue