Compare commits
No commits in common. "476209b82e2d36a20e2a0512d1e924bcc8295c75" and "866a8d41d5c196a8ae2b80baa502f59bd7a84782" have entirely different histories.
476209b82e
...
866a8d41d5
9 changed files with 60 additions and 41 deletions
|
@ -105,7 +105,7 @@ build-base-stable:
|
||||||
|
|
||||||
build-base-msrv:
|
build-base-msrv:
|
||||||
extends: build-base-stable
|
extends: build-base-stable
|
||||||
image: "rust:1.57.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.57.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.57.0"
|
image: "rust:1.54.0"
|
||||||
needs: ["build-msrv"]
|
needs: ["build-msrv"]
|
||||||
cache:
|
cache:
|
||||||
key: msrv
|
key: msrv
|
||||||
|
|
|
@ -4,13 +4,6 @@ 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).
|
||||||
|
|
||||||
## 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
|
## v0.5.2 - 2022-05-02
|
||||||
### Added
|
### Added
|
||||||
- Output now contains a reminder to use `fif --fix`
|
- Output now contains a reminder to use `fif --fix`
|
||||||
|
@ -33,7 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
|
||||||
## v0.5.0 - 2022-01-01
|
## v0.5.0 - 2022-01-01
|
||||||
### Changed
|
### Changed
|
||||||
- The Minimum Supported Rust Version (MSRV) is now **1.57.0**.
|
- 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
|
||||||
|
|
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -81,16 +81,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "3.2.20"
|
version = "3.1.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd"
|
checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
"clap_lex",
|
"clap_lex",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"once_cell",
|
"lazy_static",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
"terminal_size",
|
"terminal_size",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
|
@ -99,9 +99,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "3.2.18"
|
version = "3.1.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
|
checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
|
@ -231,7 +231,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fif"
|
name = "fif"
|
||||||
version = "0.6.0"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
@ -769,13 +769,11 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smartstring"
|
name = "smartstring"
|
||||||
version = "1.0.1"
|
version = "0.2.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29"
|
checksum = "31aa6a31c0c2b21327ce875f7e8952322acfcfd0c27569a6e18a647281352c9b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
"version_check",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
21
Cargo.toml
21
Cargo.toml
|
@ -1,11 +1,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.6.0"
|
version = "0.5.2"
|
||||||
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.57.0" # os_str_bytes requires >=1.57.0, numerous other deps require 2021 edition support
|
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"]
|
||||||
|
@ -38,7 +38,6 @@ serde_json = { version = "1.0", optional = true }
|
||||||
num_cpus = { version = "1.13.0", optional = true }
|
num_cpus = { version = "1.13.0", optional = true }
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
parking_lot = "0.12.0"
|
parking_lot = "0.12.0"
|
||||||
smartstring = "1"
|
|
||||||
|
|
||||||
[target.'cfg(not(unix))'.dependencies]
|
[target.'cfg(not(unix))'.dependencies]
|
||||||
xdg-mime = { version = "0.3.3", optional = true }
|
xdg-mime = { version = "0.3.3", optional = true }
|
||||||
|
@ -48,8 +47,20 @@ infer = "0.9.0"
|
||||||
xdg-mime = "0.3.3"
|
xdg-mime = "0.3.3"
|
||||||
infer = { version = "0.9.0", optional = true }
|
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]
|
[dependencies.clap]
|
||||||
version = "3.2"
|
version = "~3.1" # 3.2 requires rust 1.56.0
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["wrap_help", "color", "derive", "std", "unicode"]
|
features = ["wrap_help", "color", "derive", "std", "unicode"]
|
||||||
|
|
||||||
|
@ -75,4 +86,4 @@ opt-level = 3
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
msrv = "1.57.0"
|
msrv = "1.54.0"
|
||||||
|
|
|
@ -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.57.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)
|
||||||
|
|
4
build.rs
4
build.rs
|
@ -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
|
// 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.
|
// 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!
|
// 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 {
|
let hash = match git {
|
||||||
Ok(output) => String::from_utf8_lossy(&output.stdout).into(),
|
Ok(output) => String::from_utf8_lossy(&*output.stdout).into(),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// git not being present (or failing) shouldn't block compilation
|
// git not being present (or failing) shouldn't block compilation
|
||||||
println!("cargo:warning=Failed to retrieve git commit hash");
|
println!("cargo:warning=Failed to retrieve git commit hash");
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
# 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.57.0"
|
msrv = "1.54.0"
|
||||||
|
|
|
@ -163,10 +163,10 @@ fn main() {
|
||||||
// handles: --prompt never --overwrite
|
// handles: --prompt never --overwrite
|
||||||
// user specified --prompt never in conjunction with --overwrite, so always rename
|
// user specified --prompt never in conjunction with --overwrite, so always rename
|
||||||
true
|
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]
|
// handles: --prompt error --overwrite, --prompt always --overwrite [y]
|
||||||
// if the target exists, prompt before renaming; otherwise, just rename
|
// 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 {
|
} else {
|
||||||
// handles: --prompt always --overwrite [n]
|
// handles: --prompt always --overwrite [n]
|
||||||
// user was prompted and replied "no"
|
// user was prompted and replied "no"
|
||||||
|
@ -191,7 +191,7 @@ fn main() {
|
||||||
warn!("Couldn't rename {:#?} to {:#?}: {:#?}", f.file, rename_to, e);
|
warn!("Couldn't rename {:#?} to {:#?}: {:#?}", f.file, rename_to, e);
|
||||||
// if the user passed --prompt never, continue to the next file
|
// 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"
|
// 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;
|
failed += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,12 +102,11 @@ fn simple_directory() {
|
||||||
set_current_dir(dir.path()).expect("Failed to change directory.");
|
set_current_dir(dir.path()).expect("Failed to change directory.");
|
||||||
|
|
||||||
for (name, bytes) in &files {
|
for (name, bytes) in &files {
|
||||||
let mut file = File::create(dir.path().join(name))
|
let mut file = File::create(dir.path().join(name)).expect(&*format!("Failed to create file: {}", name));
|
||||||
.unwrap_or_else(|_| panic!("Failed to create file: {}", name));
|
|
||||||
|
|
||||||
file
|
file
|
||||||
.write_all(bytes)
|
.write_all(bytes)
|
||||||
.unwrap_or_else(|_| panic!("Failed to write to file: {}", name));
|
.expect(&*format!("Failed to write to file: {}", name));
|
||||||
drop(file);
|
drop(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +225,7 @@ fn argument_parsing() {
|
||||||
#[test]
|
#[test]
|
||||||
/// Ensure that `fif -e jpg dir` is interpreted as "scan for jpg files in dir" and not "scan for jpg and dir files"
|
/// 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() {
|
fn positional_args() {
|
||||||
for flag in ["-x", "-e", "-X", "-E"] {
|
for flag in &["-x", "-e", "-X", "-E"] {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Parameters::parse_from(vec!["fif", flag, "images", "directory"]).dir,
|
Parameters::parse_from(vec!["fif", flag, "images", "directory"]).dir,
|
||||||
PathBuf::from("directory")
|
PathBuf::from("directory")
|
||||||
|
@ -484,8 +483,8 @@ fn media_contains_audio_video_images() {
|
||||||
.for_each(|ext| assert!(media_exts.contains(&ext)));
|
.for_each(|ext| assert!(media_exts.contains(&ext)));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Parameters::parse_from(["fif", "-E", "media"]).extensions(),
|
Parameters::parse_from(&["fif", "-E", "media"]).extensions(),
|
||||||
Parameters::parse_from(["fif", "-E", "audio,video,images"]).extensions()
|
Parameters::parse_from(&["fif", "-E", "audio,video,images"]).extensions()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +510,7 @@ fn writables_is_correct() {
|
||||||
fn verbosity() {
|
fn verbosity() {
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
assert!(
|
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!"
|
"Failed to reject usage of both -q and -v!"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -528,7 +527,7 @@ fn verbosity() {
|
||||||
];
|
];
|
||||||
|
|
||||||
for (flags, level) in expected_results {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,3 +564,21 @@ fn sort_findings() {
|
||||||
assert_eq!(findings.next().unwrap().file, Path::new("ccc"));
|
assert_eq!(findings.next().unwrap().file, Path::new("ccc"));
|
||||||
assert_eq!(findings.next(), None);
|
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();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue