Compare commits

...

3 Commits

Author SHA1 Message Date
Lynne Megido 476209b82e
release v0.6.0 🥳 2022-09-04 13:52:37 +10:00
Lynne Megido acd33980e9
clippy cleanup 2022-09-04 13:48:54 +10:00
Lynne Megido 420bd0483c
update all dependencies, remove deprecated code 2022-09-04 13:41:41 +10:00
9 changed files with 41 additions and 60 deletions

View File

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

View File

@ -4,6 +4,13 @@ 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
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.6.0 - 2022-09-04
### Changed
- The Minimum Supported Rust Version (MSRV) is now **1.57.0**.
- Update [`clap`] to v3.2.0
- Update [`smartstring`] to v1.0 - this should (slightly) improve performance on 32-bit big endian architectures
such as PowerPC
## v0.5.2 - 2022-05-02
### Added
- Output now contains a reminder to use `fif --fix`
@ -26,7 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## v0.5.0 - 2022-01-01
### Changed
- The Minimum Supported Rust Version (MSRV) is now **1.54.0**.
- The Minimum Supported Rust Version (MSRV) is now **1.57.0**.
- Updated [`new_mime_guess`] to 4.0.0
- `--version` output now handles missing Git commit hashes, and specifies the target operating system
### Fixed

18
Cargo.lock generated
View File

@ -81,16 +81,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "3.1.18"
version = "3.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b"
checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
"indexmap",
"lazy_static",
"once_cell",
"termcolor",
"terminal_size",
"textwrap",
@ -99,9 +99,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "3.1.18"
version = "3.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c"
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
dependencies = [
"heck",
"proc-macro-error",
@ -231,7 +231,7 @@ dependencies = [
[[package]]
name = "fif"
version = "0.5.2"
version = "0.6.0"
dependencies = [
"assert_cmd",
"cfg-if",
@ -769,11 +769,13 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
[[package]]
name = "smartstring"
version = "0.2.9"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31aa6a31c0c2b21327ce875f7e8952322acfcfd0c27569a6e18a647281352c9b"
checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29"
dependencies = [
"autocfg",
"static_assertions",
"version_check",
]
[[package]]

View File

@ -1,11 +1,11 @@
[package]
name = "fif"
description = "A command-line tool for detecting and optionally correcting files with incorrect extensions."
version = "0.5.2"
version = "0.6.0"
authors = ["Lynnesbian <lynne@bune.city>"]
edition = "2018"
license = "GPL-3.0-or-later"
rust-version = "1.54.0" # clap 3 requires >=1.54.0
rust-version = "1.57.0" # os_str_bytes requires >=1.57.0, numerous other deps require 2021 edition support
repository = "https://gitlab.com/Lynnesbian/fif"
readme = "README.md"
keywords = ["mime", "mimetype", "utilities", "tools"]
@ -38,6 +38,7 @@ serde_json = { version = "1.0", optional = true }
num_cpus = { version = "1.13.0", optional = true }
maplit = "1.0.2"
parking_lot = "0.12.0"
smartstring = "1"
[target.'cfg(not(unix))'.dependencies]
xdg-mime = { version = "0.3.3", optional = true }
@ -47,20 +48,8 @@ infer = "0.9.0"
xdg-mime = "0.3.3"
infer = { version = "0.9.0", optional = true }
[target.'cfg(not(all(target_endian = "big", target_pointer_width = "32")))'.dependencies]
# the seemingly weird target constraint here is due to this:
# https://github.com/bodil/smartstring/blob/v0.2.9/src/config.rs#L91-L93
# essentially, smartstring is intentionally blocked from compiling on 32-bit big endian archs, so our dependency on it
# needs to be too. otherwise, fif won't work on platforms like powerpc, even though this dependency is the only
# blocker -- fif runs just fine on powerpc (or on my powerbook G4, anyway) without smartstring.
# additionally, versions before 0.2.4 didn't impl Display, so we need at least that version for displaying Strings.
# version 1.0 of smartstring adds 32-bit BE compatibility (by rewriting the implementation), but requires rust 1.57.0,
# so we can't use it.
smartstring = ">= 0.2.4, <=0.2.9"
[dependencies.clap]
version = "~3.1" # 3.2 requires rust 1.56.0
version = "3.2"
default-features = false
features = ["wrap_help", "color", "derive", "std", "unicode"]
@ -86,4 +75,4 @@ opt-level = 3
opt-level = 3
[package.metadata]
msrv = "1.54.0"
msrv = "1.57.0"

View File

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

View File

@ -14,9 +14,9 @@ fn main() -> Result<(), String> {
// a more robust way of doing this would be to use vergen (https://github.com/rustyhorde/vergen), but it pulls in a
// whole bunch of extra dependencies (including chrono and git2), and also blocks compilation on the current MSRV.
// this method is less clever and robust, but it works!
let git = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output();
let git = Command::new("git").args(["rev-parse", "--short", "HEAD"]).output();
let hash = match git {
Ok(output) => String::from_utf8_lossy(&*output.stdout).into(),
Ok(output) => String::from_utf8_lossy(&output.stdout).into(),
Err(_) => {
// git not being present (or failing) shouldn't block compilation
println!("cargo:warning=Failed to retrieve git commit hash");

View File

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

View File

@ -163,10 +163,10 @@ fn main() {
// handles: --prompt never --overwrite
// user specified --prompt never in conjunction with --overwrite, so always rename
true
} else if prompt == Prompt::Error || ask(&*format!("Rename {:#?} to {:#?}?", &f.file, &rename_to)) {
} else if prompt == Prompt::Error || ask(&format!("Rename {:#?} to {:#?}?", &f.file, &rename_to)) {
// handles: --prompt error --overwrite, --prompt always --overwrite [y]
// if the target exists, prompt before renaming; otherwise, just rename
!rename_to.exists() || ask(&*format!("Destination {:#?} already exists, overwrite?", rename_to))
!rename_to.exists() || ask(&format!("Destination {:#?} already exists, overwrite?", rename_to))
} else {
// handles: --prompt always --overwrite [n]
// user was prompted and replied "no"
@ -191,7 +191,7 @@ fn main() {
warn!("Couldn't rename {:#?} to {:#?}: {:#?}", f.file, rename_to, e);
// if the user passed --prompt never, continue to the next file
// otherwise, prompt user to retry move, retrying until the rename succeeds or they respond "N"
if prompt == Prompt::Never || !ask(&*format!("Error while renaming file: {:#?}. Try again?", e)) {
if prompt == Prompt::Never || !ask(&format!("Error while renaming file: {:#?}. Try again?", e)) {
failed += 1;
break;
}

View File

@ -102,11 +102,12 @@ fn simple_directory() {
set_current_dir(dir.path()).expect("Failed to change directory.");
for (name, bytes) in &files {
let mut file = File::create(dir.path().join(name)).expect(&*format!("Failed to create file: {}", name));
let mut file = File::create(dir.path().join(name))
.unwrap_or_else(|_| panic!("Failed to create file: {}", name));
file
.write_all(bytes)
.expect(&*format!("Failed to write to file: {}", name));
.unwrap_or_else(|_| panic!("Failed to write to file: {}", name));
drop(file);
}
@ -225,7 +226,7 @@ fn argument_parsing() {
#[test]
/// Ensure that `fif -e jpg dir` is interpreted as "scan for jpg files in dir" and not "scan for jpg and dir files"
fn positional_args() {
for flag in &["-x", "-e", "-X", "-E"] {
for flag in ["-x", "-e", "-X", "-E"] {
assert_eq!(
Parameters::parse_from(vec!["fif", flag, "images", "directory"]).dir,
PathBuf::from("directory")
@ -483,8 +484,8 @@ fn media_contains_audio_video_images() {
.for_each(|ext| assert!(media_exts.contains(&ext)));
assert_eq!(
Parameters::parse_from(&["fif", "-E", "media"]).extensions(),
Parameters::parse_from(&["fif", "-E", "audio,video,images"]).extensions()
Parameters::parse_from(["fif", "-E", "media"]).extensions(),
Parameters::parse_from(["fif", "-E", "audio,video,images"]).extensions()
);
}
@ -510,7 +511,7 @@ fn writables_is_correct() {
fn verbosity() {
use log::LevelFilter;
assert!(
Parameters::try_parse_from(&["fif", "-q", "-v"]).is_err(),
Parameters::try_parse_from(["fif", "-q", "-v"]).is_err(),
"Failed to reject usage of both -q and -v!"
);
@ -527,7 +528,7 @@ fn verbosity() {
];
for (flags, level) in expected_results {
assert_eq!(Parameters::parse_from(&["fif", flags]).get_verbosity(), level);
assert_eq!(Parameters::parse_from(["fif", flags]).get_verbosity(), level);
}
}
@ -564,21 +565,3 @@ fn sort_findings() {
assert_eq!(findings.next().unwrap().file, Path::new("ccc"));
assert_eq!(findings.next(), None);
}
#[test]
#[cfg(not(all(target_endian = "big", target_pointer_width = "32")))]
/// Ensures that [`SmartString`]s don't deviate from std's Strings
// remove this when (if) updating to smartstring v1.0!
fn validate_string_type() {
use std::string::String as StdString;
use fif::String as SmartString;
assert_eq!(SmartString::new(), StdString::new());
assert_eq!(SmartString::from("smol"), StdString::from("smol"));
assert_eq!(
SmartString::from("A long and therefore heap-allocated string"),
StdString::from("A long and therefore heap-allocated string")
);
smartstring::validate();
}