Compare commits
No commits in common. "672cc8da908146f62029125e1d4deec58725c8d7" and "480acf515f018b62c08d69cec94f07d333fdc839" have entirely different histories.
672cc8da90
...
480acf515f
9 changed files with 15 additions and 36 deletions
|
@ -37,7 +37,6 @@ stages:
|
|||
script:
|
||||
- cargo install cargo-sweep
|
||||
- cargo sweep -i
|
||||
- git -C $CI_PROJECT_DIR/.cargo/registry/index/github.com-1ecc6299db9ec823/ gc || true
|
||||
|
||||
# this builds a "base" version of fif with default features enabled. this is done separately from the main build step
|
||||
# for the purposes of caching - by building once *before* executing the parallel cargo-build step, we ensure that
|
||||
|
@ -60,7 +59,7 @@ stages:
|
|||
- multi-threaded infer-backend
|
||||
|
||||
script:
|
||||
cargo run --no-default-features --locked --features="json $FEATURES" -- --version
|
||||
cargo build --no-default-features --locked --features="json $FEATURES"
|
||||
|
||||
# test with various features on and off.
|
||||
.cargo-test:
|
||||
|
|
|
@ -4,7 +4,7 @@ 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.4.0 - 2021-10-14
|
||||
## Unreleased
|
||||
### Added
|
||||
- `--fix` mode - instead of outputting a shell script or text file, fif will rename the misnamed files for you!
|
||||
- By default, the user will be prompted only if fif encounters an error while renaming the file, or if renaming
|
||||
|
@ -23,8 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||
- Output is now sorted by filename - specifically, errors will appear first, followed by files that fif is unable to
|
||||
recommend an extension for, in order of filename, followed by files that fif knows how to rename, again in order
|
||||
of filename.
|
||||
### Other
|
||||
- [Reuse](https://reuse.software) compliance
|
||||
---
|
||||
|
||||
## v0.3.7 - 2021-09-25
|
||||
### Added
|
||||
|
|
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -175,7 +175,7 @@ checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
|
|||
|
||||
[[package]]
|
||||
name = "fif"
|
||||
version = "0.4.0"
|
||||
version = "0.3.7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"clap",
|
||||
|
@ -454,9 +454,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.30"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70"
|
||||
checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
@ -648,9 +648,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.80"
|
||||
version = "1.0.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194"
|
||||
checksum = "a4eac2e6c19f5c3abc0c229bea31ff0b9b091c7b14990e8924b92902a303a0c0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -702,18 +702,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.30"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
|
||||
checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.30"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
|
||||
checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
[package]
|
||||
name = "fif"
|
||||
description = "A command-line tool for detecting and optionally correcting files with incorrect extensions."
|
||||
version = "0.4.0"
|
||||
version = "0.3.7"
|
||||
authors = ["Lynnesbian <lynne@bune.city>"]
|
||||
edition = "2018"
|
||||
license = "GPL-3.0-or-later"
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
](https://github.com/rust-secure-code/safety-dance/)
|
||||
[![Dependency versions](https://deps.rs/repo/gitlab/lynnesbian/fif/status.svg)
|
||||
](https://deps.rs/repo/gitlab/lynnesbian/fif)
|
||||
[![REUSE status](https://api.reuse.software/badge/gitlab.com/Lynnesbian/fif/)
|
||||
](https://api.reuse.software/info/gitlab.com/Lynnesbian/fif/)
|
||||
|
||||
*A command-line tool for detecting and optionally correcting files with incorrect extensions.*
|
||||
</div>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
@ -183,7 +183,7 @@ pub fn scan_from_walkdir(
|
|||
}
|
||||
|
||||
/// Scans a given directory with [`WalkDir`], filters with [`wanted_file`], checks for errors, and returns a vector of
|
||||
/// [`DirEntry`]s.
|
||||
/// [DirEntry]s.
|
||||
pub fn scan_directory(
|
||||
dirs: &Path,
|
||||
exts: Option<&BTreeSet<&str>>,
|
||||
|
|
|
@ -316,7 +316,7 @@ impl FormatSteps for Text {
|
|||
smart_write(
|
||||
f,
|
||||
// writablesln![Newline, "Processed ", (entries.len().to_string().as_str()), " files"],
|
||||
&[Writable::Newline],
|
||||
writablesln![Newline, "Done."],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -147,10 +147,6 @@ fn main() {
|
|||
|
||||
let prompt = args.prompt.unwrap_or(Prompt::Error);
|
||||
|
||||
let mut renamed = 0_u32; // files that were successfully renamed
|
||||
let mut skipped = 0_u32; // files that were skipped over without trying to rename
|
||||
let mut failed = 0_u32; // files that fif failed to rename - e.g. files that are exclusively locked
|
||||
|
||||
for f in findings {
|
||||
if let Some(rename_to) = f.recommended_path() {
|
||||
let will_rename = {
|
||||
|
@ -175,16 +171,13 @@ fn main() {
|
|||
};
|
||||
|
||||
if !will_rename {
|
||||
skipped += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
loop {
|
||||
// until file is renamed successfully
|
||||
match std::fs::rename(&f.file, &rename_to) {
|
||||
Ok(_) => {
|
||||
info!("Renamed {:#?} -> {:#?}", f.file, rename_to);
|
||||
renamed += 1;
|
||||
break;
|
||||
}
|
||||
Err(e) => {
|
||||
|
@ -192,7 +185,6 @@ fn main() {
|
|||
// 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)) {
|
||||
failed += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -201,17 +193,8 @@ fn main() {
|
|||
} else {
|
||||
// no recommended name :c
|
||||
info!("No known extension for file {:#?} of type {}", f.file, f.mime);
|
||||
skipped += 1;
|
||||
}
|
||||
}
|
||||
|
||||
info!(
|
||||
"Processed {} files: Renamed {}, skipped {}, failed to rename {}",
|
||||
renamed + skipped + failed,
|
||||
renamed,
|
||||
skipped,
|
||||
failed
|
||||
);
|
||||
} else {
|
||||
let mut buffered_stdout = BufWriter::new(stdout());
|
||||
|
||||
|
|
Loading…
Reference in a new issue