Compare commits

..

No commits in common. "e1930c34b9ec0a418034247371bb6ee7d08cb9dd" and "6a712a0302bc72d52872ec1c88200a7d8196d1eb" have entirely different histories.

5 changed files with 18 additions and 58 deletions

3
.gitignore vendored
View file

@ -1,3 +1,2 @@
/target /target
/releases /releases
.intentionally-empty-file.o

2
Cargo.lock generated
View file

@ -153,7 +153,7 @@ dependencies = [
[[package]] [[package]]
name = "sidestepper" name = "sidestepper"
version = "5.3.6" version = "5.3.5"
dependencies = [ dependencies = [
"ignore", "ignore",
] ]

View file

@ -1,13 +1,7 @@
[package] [package]
name = "sidestepper" name = "sidestepper"
version = "5.3.6" version = "5.3.5"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
ignore = "0.4.23" ignore = "0.4.23"
[profile.release]
strip = true
lto = true
codegen-units = 1
opt-level = "z"

View file

@ -22,7 +22,7 @@
}; };
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rustup rustc cargo cargo-zigbuild zig ]; nativeBuildInputs = with pkgs; [ rustc cargo cargo-zigbuild zig ];
}; };
} }
); );

View file

@ -24,16 +24,12 @@ use std::time::{Duration, SystemTime};
use std::{env, fs, io, path}; use std::{env, fs, io, path};
const SOTA_SIDESTEP_LARGE_FILE_SIZE: u64 = 100000000; // 100mb const SOTA_SIDESTEP_LARGE_FILE_SIZE: u64 = 100000000; // 100mb
const VERSION_OVERALL: u8 = 5;
const VERSION_IMPLEMENTATION: u8 = 3;
const VERSION_ALGORITHM: u8 = 6;
struct Behaviour { struct Behaviour {
repo_dir_path: PathBuf, repo_dir_path: PathBuf,
repo_sotaignore_path: PathBuf, repo_sotaignore_path: PathBuf,
large_file_size: u64, large_file_size: u64,
plumbing: bool, plumbing: bool,
version: bool,
} }
fn cli_get_behaviour() -> Result<Behaviour, Box<dyn Error>> { fn cli_get_behaviour() -> Result<Behaviour, Box<dyn Error>> {
@ -53,15 +49,6 @@ fn cli_get_behaviour() -> Result<Behaviour, Box<dyn Error>> {
if arg == "--plumbing" { if arg == "--plumbing" {
plumbing = true; plumbing = true;
} }
if arg == "--version" {
return Ok(Behaviour {
repo_dir_path: PathBuf::new(),
repo_sotaignore_path: PathBuf::new(),
large_file_size,
plumbing,
version: true,
});
}
} }
let current_dir = env::current_dir().map_err(|_| "could not get current working directory")?; let current_dir = env::current_dir().map_err(|_| "could not get current working directory")?;
@ -73,7 +60,6 @@ fn cli_get_behaviour() -> Result<Behaviour, Box<dyn Error>> {
repo_sotaignore_path: PathBuf::from(&current_dir.join(".sotaignore")), repo_sotaignore_path: PathBuf::from(&current_dir.join(".sotaignore")),
large_file_size, large_file_size,
plumbing, plumbing,
version: false,
}); });
} }
@ -98,7 +84,6 @@ fn cli_get_behaviour() -> Result<Behaviour, Box<dyn Error>> {
repo_sotaignore_path: PathBuf::from(&repo_dir_path.join(".sotaignore")), repo_sotaignore_path: PathBuf::from(&repo_dir_path.join(".sotaignore")),
large_file_size, large_file_size,
plumbing, plumbing,
version: false,
}) })
} }
@ -156,26 +141,20 @@ fn ss_write_sotaignore(behaviour: &Behaviour, large_files: &Vec<PathBuf>) -> io:
let mut new_sotaignore = old_sotaignore.clone(); let mut new_sotaignore = old_sotaignore.clone();
for file in large_files { for file in large_files {
if let Ok(file_relative) = file.strip_prefix(&behaviour.repo_dir_path) { if let Ok(file_relative) = file.strip_prefix(&behaviour.repo_dir_path) {
let posix_relative_path_str = { let fallback = &file.to_string_lossy();
// try: let relative_path_str = file_relative
// - valid unicode relative path (may fail) .to_str()
// - valid unicode absolute path (may fail) .unwrap_or(file.to_str().unwrap_or(fallback));
// - potentially invalid unicode absolute path (always returns)
let relative_path_str = file_relative
.to_str()
.unwrap_or(file.to_str().unwrap_or(&file.to_string_lossy()))
.to_string();
// posix-path-ify it for cross compatibility // posix-path-ify it for cross compatibility
if path::MAIN_SEPARATOR_STR == "\\" { if !old_sotaignore.contains(&relative_path_str.to_string()) {
relative_path_str.to_string().replace("\\", "/") new_sotaignore.push({
} else { if path::MAIN_SEPARATOR_STR == "\\" {
relative_path_str.to_string() relative_path_str.to_string().replace("\\", "/")
} } else {
}; relative_path_str.to_string()
}
if !old_sotaignore.contains(&posix_relative_path_str) { })
new_sotaignore.push(posix_relative_path_str)
} }
} }
} }
@ -218,10 +197,7 @@ fn format_elapsed_time(secs: f64) -> String {
} }
fn main() { fn main() {
eprintln!( eprintln!("sota staircase SideStepper v5 (i3/a5)");
"sota staircase SideStepper v{} (i{}/a{})",
VERSION_OVERALL, VERSION_IMPLEMENTATION, VERSION_ALGORITHM
);
let behaviour = { let behaviour = {
let behaviour = cli_get_behaviour(); let behaviour = cli_get_behaviour();
// huh. pattern matching consumes the variable, so we ref (&) it. damn. // huh. pattern matching consumes the variable, so we ref (&) it. damn.
@ -232,15 +208,6 @@ fn main() {
behaviour.unwrap() behaviour.unwrap()
}; };
// check if we're just printing the version
if behaviour.version {
println!(
"v{}.{}.{}",
VERSION_OVERALL, VERSION_IMPLEMENTATION, VERSION_ALGORITHM
);
exit(0);
}
eprintln!( eprintln!(
" repo root : {}\n .sotaignore : {}\n", " repo root : {}\n .sotaignore : {}\n",
behaviour.repo_dir_path.to_string_lossy(), behaviour.repo_dir_path.to_string_lossy(),