release v0.5.0 🥳

This commit is contained in:
Lynne Megido 2022-01-01 13:28:45 +10:00
parent 9aef5d314c
commit c06a7a527a
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
9 changed files with 48 additions and 59 deletions

View file

@ -105,7 +105,7 @@ build-base-stable:
build-base-msrv: build-base-msrv:
extends: build-base-stable extends: build-base-stable
image: "rust:1.48.0" image: "rust:1.54.0"
cache: cache:
key: msrv key: msrv
paths: paths:
@ -131,7 +131,7 @@ build-stable:
build-msrv: build-msrv:
extends: build-stable extends: build-stable
needs: ["build-base-msrv"] needs: ["build-base-msrv"]
image: "rust:1.48.0" image: "rust:1.54.0"
cache: cache:
key: msrv key: msrv
paths: paths:
@ -156,7 +156,7 @@ test-stable:
test-msrv: test-msrv:
extends: test-stable extends: test-stable
image: "rust:1.48.0" image: "rust:1.54.0"
needs: ["build-msrv"] needs: ["build-msrv"]
cache: cache:
key: msrv key: msrv

View file

@ -4,8 +4,9 @@ Dates are given in YYYY-MM-DD format - for example, the 15th of October 2021 is
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased ## v0.5.0 - 2022-01-01
### Changed ### Changed
- The Minimum Supported Rust Version (MSRV) is now **1.54.0**.
- Updated [`new_mime_guess`] to 4.0.0 - Updated [`new_mime_guess`] to 4.0.0
- `--version` output now handles missing Git commit hashes, and specifies the target operating system - `--version` output now handles missing Git commit hashes, and specifies the target operating system
### Fixed ### Fixed

42
Cargo.lock generated
View file

@ -2,15 +2,6 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 3
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.5.2" version = "0.5.2"
@ -89,9 +80,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.0.0-beta.2" version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142" checksum = "d17bf219fcd37199b9a29e00ba65dfb8cd5b2688b7297ec14ff829c40ac50ca9"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
@ -102,15 +93,14 @@ dependencies = [
"termcolor", "termcolor",
"terminal_size", "terminal_size",
"textwrap", "textwrap",
"unicode-width", "unicase",
"vec_map",
] ]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "3.0.0-beta.2" version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1" checksum = "e1b9752c030a14235a0bd5ef3ad60a1dcac8468c30921327fc8af36b20c790b9"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -221,12 +211,11 @@ checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
[[package]] [[package]]
name = "fif" name = "fif"
version = "0.4.0" version = "0.5.0"
dependencies = [ dependencies = [
"assert_cmd", "assert_cmd",
"cfg-if", "cfg-if",
"clap", "clap",
"clap_derive",
"env_logger", "env_logger",
"exitcode", "exitcode",
"infer", "infer",
@ -445,9 +434,12 @@ checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
[[package]] [[package]]
name = "os_str_bytes" name = "os_str_bytes"
version = "2.4.0" version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85" checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
@ -678,8 +670,6 @@ version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [ dependencies = [
"aho-corasick",
"memchr",
"regex-syntax", "regex-syntax",
] ]
@ -845,9 +835,9 @@ checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16"
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.12.1" version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789" checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
dependencies = [ dependencies = [
"terminal_size", "terminal_size",
"unicode-width", "unicode-width",
@ -912,12 +902,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"

View file

@ -4,11 +4,11 @@
[package] [package]
name = "fif" name = "fif"
description = "A command-line tool for detecting and optionally correcting files with incorrect extensions." description = "A command-line tool for detecting and optionally correcting files with incorrect extensions."
version = "0.4.0" version = "0.5.0"
authors = ["Lynnesbian <lynne@bune.city>"] authors = ["Lynnesbian <lynne@bune.city>"]
edition = "2018" edition = "2018"
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
rust-version = "1.48.0" # this can actually go as low as 1.41.0 after removing cached, but i'll leave it 1.43.0 rust-version = "1.54.0" # clap 3 requires >=1.54.0
repository = "https://gitlab.com/Lynnesbian/fif" repository = "https://gitlab.com/Lynnesbian/fif"
readme = "README.md" readme = "README.md"
keywords = ["mime", "mimetype", "utilities", "tools"] keywords = ["mime", "mimetype", "utilities", "tools"]
@ -62,13 +62,9 @@ smartstring = ">= 0.2.4"
[dependencies.clap] [dependencies.clap]
# beta.4 requires rust >= 1.54.0 (and beta.3 was yanked) # beta.4 requires rust >= 1.54.0 (and beta.3 was yanked)
version = "=3.0.0-beta.2" version = "3.0.0"
default-features = false default-features = false
features = ["wrap_help", "color", "derive", "std"] features = ["wrap_help", "color", "derive", "std", "unicode"]
[dependencies.clap_derive]
# without this, clap beta.2 will install clap_derive beta.4 :c
version = "=3.0.0-beta.2"
[dependencies.env_logger] [dependencies.env_logger]
version = "0.9.0" version = "0.9.0"
@ -79,7 +75,7 @@ features = ["termcolor", "atty"]
tempfile = "3.2.0" tempfile = "3.2.0"
rand = "0.8.3" rand = "0.8.3"
assert_cmd = "2.0.2" assert_cmd = "2.0.2"
regex = "1.5.4" regex = { version = "1.5.4", default-features = false, features = ["std"] }
[profile.release] [profile.release]
lto = "thin" lto = "thin"
@ -92,4 +88,4 @@ opt-level = 3
opt-level = 3 opt-level = 3
[package.metadata] [package.metadata]
msrv = "1.48.0" msrv = "1.54.0"

View file

@ -7,7 +7,7 @@
[![Version](https://img.shields.io/crates/v/fif.svg?logo=rust&style=flat-square) [![Version](https://img.shields.io/crates/v/fif.svg?logo=rust&style=flat-square)
](https://crates.io/crates/fif) ](https://crates.io/crates/fif)
[![Minimum Supported Rust Version](https://img.shields.io/badge/msrv-1.48.0-orange?logo=rust&style=flat-square) [![Minimum Supported Rust Version](https://img.shields.io/badge/msrv-1.54.0-orange?logo=rust&style=flat-square)
](https://gitlab.com/Lynnesbian/fif/-/blob/master/README.md#version-policy) ](https://gitlab.com/Lynnesbian/fif/-/blob/master/README.md#version-policy)
[![License](https://img.shields.io/crates/l/fif.svg?style=flat-square) [![License](https://img.shields.io/crates/l/fif.svg?style=flat-square)
](https://gitlab.com/Lynnesbian/fif/-/blob/master/LICENSE) ](https://gitlab.com/Lynnesbian/fif/-/blob/master/LICENSE)

View file

@ -3,4 +3,4 @@
# avoid-breaking-exported-api = false # only available on nightly for now # avoid-breaking-exported-api = false # only available on nightly for now
cognitive-complexity-threshold = 15 cognitive-complexity-threshold = 15
msrv = "1.48.0" msrv = "1.54.0"

View file

@ -16,7 +16,7 @@ use std::io::{stdin, stdout, BufWriter, Write};
use std::process::exit; use std::process::exit;
use cfg_if::cfg_if; use cfg_if::cfg_if;
use clap::Clap; use clap::Parser;
use fif::files::{scan_directory, scan_from_walkdir}; use fif::files::{scan_directory, scan_from_walkdir};
use fif::formats::{self, Format}; use fif::formats::{self, Format};
use fif::parameters::{self, OutputFormat, Prompt}; use fif::parameters::{self, OutputFormat, Prompt};

View file

@ -7,7 +7,7 @@ use std::collections::BTreeSet;
use std::path::PathBuf; use std::path::PathBuf;
use cfg_if::cfg_if; use cfg_if::cfg_if;
use clap::{AppSettings, Clap}; use clap::{Parser, ArgEnum};
use crate::utils::{CLAP_LONG_VERSION, CLAP_VERSION}; use crate::utils::{CLAP_LONG_VERSION, CLAP_VERSION};
use crate::String as StringType; use crate::String as StringType;
@ -22,7 +22,7 @@ cfg_if! {
} }
} }
#[derive(Clap, PartialEq, Debug, Copy, Clone)] #[derive(ArgEnum, PartialEq, Debug, Copy, Clone)]
/// The format to use when running fif without the `--fix` flag. Specified at runtime with the `-o`/`--output-format` /// The format to use when running fif without the `--fix` flag. Specified at runtime with the `-o`/`--output-format`
/// flag. /// flag.
pub enum OutputFormat { pub enum OutputFormat {
@ -39,7 +39,7 @@ pub enum OutputFormat {
Json, Json,
} }
#[derive(Clap, PartialEq, Debug, Copy, Clone)] #[derive(ArgEnum, PartialEq, Debug, Copy, Clone)]
/// Specifies under what conditions the user should be prompted when running fif in `--fix` mode. Defaults to `Error`. /// Specifies under what conditions the user should be prompted when running fif in `--fix` mode. Defaults to `Error`.
/// Specified at runtime with the `-p`/`--prompt` flag. /// Specified at runtime with the `-p`/`--prompt` flag.
pub enum Prompt { pub enum Prompt {
@ -51,7 +51,7 @@ pub enum Prompt {
Always, Always,
} }
#[derive(Clap, Debug)] #[derive(Parser, Debug)]
#[allow(clippy::struct_excessive_bools)] #[allow(clippy::struct_excessive_bools)]
#[clap( #[clap(
version = CLAP_VERSION.as_str(), version = CLAP_VERSION.as_str(),
@ -63,7 +63,6 @@ pub enum Prompt {
This program is free software: you can redistribute it and/or modify \ This program is free software: you can redistribute it and/or modify \
it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 \ it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 \
of the License, or (at your option) any later version.", of the License, or (at your option) any later version.",
setting(AppSettings::ColoredHelp),
max_term_width = 120 max_term_width = 120
)] )]
/// [`Clap`]-derived struct used to parse command line arguments. /// [`Clap`]-derived struct used to parse command line arguments.
@ -88,7 +87,7 @@ pub struct Parameters {
/// Only examine files with these extensions. /// Only examine files with these extensions.
/// Multiple extensions can be specified by either using the flag multiple times (`-e jpg -e png -e gif`), or by /// Multiple extensions can be specified by either using the flag multiple times (`-e jpg -e png -e gif`), or by
/// separating them with commas (`-e jpg,png,gif`). /// separating them with commas (`-e jpg,png,gif`).
#[clap(short, long, use_delimiter = true, require_delimiter = true, value_name = "ext", validator = lowercase_exts)] #[clap(short, long, use_delimiter = true, require_delimiter = true, value_name = "ext", takes_value = true, validator = validate_exts)]
pub exts: Option<Vec<StringType>>, pub exts: Option<Vec<StringType>>,
/// Use these preset lists of extensions as the search filter (comma-separated list). /// Use these preset lists of extensions as the search filter (comma-separated list).
@ -106,7 +105,8 @@ pub struct Parameters {
/// Don't scan files with these extensions. /// Don't scan files with these extensions.
/// This option takes precedence over extensions specified with `-e` or `-E`. /// This option takes precedence over extensions specified with `-e` or `-E`.
#[clap(short = 'x', long, use_delimiter = true, require_delimiter = true, value_name = "ext", validator = lowercase_exts)] #[clap(short = 'x', long, use_delimiter = true, require_delimiter = true, value_name = "ext", validator =
validate_exts)]
pub exclude: Option<Vec<StringType>>, pub exclude: Option<Vec<StringType>>,
/// Exclude files using a preset list of extensions. /// Exclude files using a preset list of extensions.
@ -177,9 +177,15 @@ pub struct Parameters {
pub jobs: usize, pub jobs: usize,
} }
/// Validation function for argument parsing that ensures passed-in extensions are lowercase. /// Validation function for argument parsing that ensures passed-in extensions are lowercase, and that the user
fn lowercase_exts(exts: &str) -> Result<(), String> { /// didn't supply an empty list.
fn validate_exts(exts: &str) -> Result<(), String> {
// TODO: i would much rather accept uppercase exts and convert them to lowercase than just rejecting lowercase exts... // TODO: i would much rather accept uppercase exts and convert them to lowercase than just rejecting lowercase exts...
if exts.is_empty() {
return Err(String::from("Cannot specify empty extensions"));
}
if exts.to_lowercase() != exts { if exts.to_lowercase() != exts {
return Err(String::from("Supplied extensions must be lowercase")); return Err(String::from("Supplied extensions must be lowercase"));
} }
@ -290,7 +296,7 @@ impl Parameters {
} }
/// Sets of extensions for use with [Parameter](crate::parameters::Parameters)'s `-E` flag. /// Sets of extensions for use with [Parameter](crate::parameters::Parameters)'s `-E` flag.
#[derive(Clap, PartialEq, Debug, Copy, Clone)] #[derive(ArgEnum, PartialEq, Debug, Copy, Clone)]
pub enum ExtensionSet { pub enum ExtensionSet {
/// Extensions used for image file formats, such as `png`, `jpeg`, `webp`, etc. /// Extensions used for image file formats, such as `png`, `jpeg`, `webp`, etc.
Images, Images,

View file

@ -6,7 +6,7 @@ use std::collections::{BTreeMap, HashMap};
use std::ffi::OsStr; use std::ffi::OsStr;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use clap::Clap; use clap::Parser;
use fif::files::{mime_extension_lookup, scan_directory, scan_from_walkdir, BUF_SIZE}; use fif::files::{mime_extension_lookup, scan_directory, scan_from_walkdir, BUF_SIZE};
use fif::findings::Findings; use fif::findings::Findings;
use fif::formats::{Format, PowerShell, Shell}; use fif::formats::{Format, PowerShell, Shell};
@ -306,6 +306,8 @@ fn rejects_bad_args() {
vec!["fif", "-X", "pebis"], vec!["fif", "-X", "pebis"],
// `-e` with nothing but commas: // `-e` with nothing but commas:
vec!["fif", "-e", ",,,,,"], vec!["fif", "-e", ",,,,,"],
// `-x` with nothing but commas:
vec!["fif", "-x", ",,,,,"],
// `-j` with a negative value: // `-j` with a negative value:
vec!["fif", "-j", "-1"], vec!["fif", "-j", "-1"],
// `--prompt` without `--fix`: // `--prompt` without `--fix`:
@ -357,7 +359,7 @@ fn check_version_output() {
let output = cmd.arg("-V").ok().unwrap().stdout; let output = cmd.arg("-V").ok().unwrap().stdout;
let output = String::from_utf8(output).unwrap(); let output = String::from_utf8(output).unwrap();
assert!( assert!(
Regex::new(r#"fif v(\d\.){2}\d"#).unwrap().is_match(output.trim()), Regex::new(r#"fif v([0-9]\.){2}[0-9]"#).unwrap().is_match(output.trim()),
"\"{}\" does not match the expected `-v` format!", "\"{}\" does not match the expected `-v` format!",
output output
); );
@ -368,7 +370,7 @@ fn check_version_output() {
let output = cmd.arg("--version").ok().unwrap().stdout; let output = cmd.arg("--version").ok().unwrap().stdout;
let output = String::from_utf8(output).unwrap(); let output = String::from_utf8(output).unwrap();
assert!( assert!(
Regex::new(r#"fif v(\d\.){2}\d \(.+, .+ backend, (unknown commit|commit #[\da-f]{7})\)"#) Regex::new(r#"fif v([0-9]\.){2}[0-9] \(.+, .+ backend, (unknown commit|commit #[[:xdigit:]]{7})\)"#)
.unwrap() .unwrap()
.is_match(output.trim()), .is_match(output.trim()),
"\"{}\" does not match the expected `--version` format!", "\"{}\" does not match the expected `--version` format!",