Skip to content

Commit 1077fe7

Browse files
authored
build(deps): Update dependencies (#208)
* build(deps): Upgrade deps. * chore: Upgrade to Rust edition 2024. * fix: Cargo format.
1 parent 6d5f3ea commit 1077fe7

8 files changed

Lines changed: 1127 additions & 873 deletions

File tree

Cargo.lock

Lines changed: 1016 additions & 764 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,54 @@ name = "dotter"
33
version = "0.13.5"
44
authors = ["SuperCuber <amit.gold01@gmail.com>"]
55
description = "A dotfile manager and templater written in rust"
6-
edition = "2021"
6+
edition = "2024"
77
repository = "https://github.com/SuperCuber/dotter"
88
readme = "README.md"
99
keywords = ["dotter", "dotfiles", "manager"]
1010
categories = ["command-line-utilities"]
1111
license = "Unlicense"
12-
rust-version = "1.70"
12+
rust-version = "1.85"
1313

1414
[dependencies]
1515
anyhow = "1.*"
16-
clap = { version = "4.0.26", features = ["derive"] }
17-
clap_complete = "4.0.5"
18-
crossterm = "0.25.0"
16+
clap = { version = "4.4.18", features = ["derive"] }
17+
clap_complete = "4.4.10"
18+
crossterm = "0.29.0"
1919
diff = "0.1.*"
2020
handlebars = "6.*"
2121
hostname = "0.3.*"
2222
log = "0.4.*"
2323
maplit = "1.*"
24-
evalexpr = "11"
24+
evalexpr = "13"
2525
serde = { version = "1.*", features = ["derive"] }
2626
shellexpand = "2.*"
2727
simplelog = "0.12.*"
2828
tokio = "1.*"
29-
toml = "0.4.*"
30-
watchexec = { version = "3", optional = true }
31-
watchexec-events = { version = "2.0.1", optional = true }
32-
watchexec-filterer-tagged = { version = "1.0.0", optional = true }
29+
toml = "0.9.6"
30+
watchexec = { version = "8", optional = true }
31+
watchexec-events = { version = "6.0.0", optional = true }
32+
watchexec-filterer-globset = { version = "8", optional = true }
3333

3434
[features]
3535
default = ["scripting", "watch"]
3636
scripting = ["handlebars/script_helper"]
37-
watch = ["watchexec", "watchexec-events", "watchexec-filterer-tagged"]
37+
watch = ["watchexec", "watchexec-events", "watchexec-filterer-globset"]
3838

3939
[dependencies.handlebars_misc_helpers]
4040
version = "0.17.*"
4141
default-features = false
4242
features = ["string", "json"]
4343

4444
[dev-dependencies]
45-
mockall = "0.11.3"
45+
mockall = "0.12.1"
4646
# Enable this instead for better failure messages (on nightly only)
4747
# mockall = { version = "0.9.*", features = ["nightly"] }
4848

4949
[target.'cfg(windows)'.dependencies]
5050
dunce = "1.*"
5151

5252
[target.'cfg(unix)'.dependencies]
53-
libc = "0.2.137"
53+
libc = "0.2.180"
5454

5555
[profile.release]
5656
strip = true

src/actions.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,10 @@ pub fn create_symlink(
269269
Ok(true)
270270
}
271271
SymlinkComparison::Identical => {
272-
warn!("Creating symlink {:?} -> {:?} but target already exists and points at source. Adding to cache anyways", source, target.target);
272+
warn!(
273+
"Creating symlink {:?} -> {:?} but target already exists and points at source. Adding to cache anyways",
274+
source, target.target
275+
);
273276
Ok(true)
274277
}
275278
SymlinkComparison::OnlyTargetExists | SymlinkComparison::BothMissing => {

src/config.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -256,25 +256,24 @@ pub fn save_dummy_config(
256256
}
257257

258258
fn recursive_extend_map(
259-
original: &mut BTreeMap<String, toml::Value>,
260-
new: BTreeMap<String, toml::Value>,
259+
original: &mut toml::map::Map<String, toml::Value>,
260+
new: toml::map::Map<String, toml::Value>,
261261
) {
262262
for (key, new_value) in new {
263-
original
264-
.entry(key)
265-
.and_modify(|original_value| {
266-
match (
267-
original_value.as_table().cloned(),
268-
new_value.as_table().cloned(),
269-
) {
270-
(Some(mut original_table), Some(new_table)) => {
271-
recursive_extend_map(&mut original_table, new_table);
272-
*original_value = original_table.into();
273-
}
274-
_ => *original_value = new_value.clone(),
263+
if let Some(original_value) = original.get_mut(&key) {
264+
match (
265+
original_value.as_table().cloned(),
266+
new_value.as_table().cloned(),
267+
) {
268+
(Some(mut original_table), Some(new_table)) => {
269+
recursive_extend_map(&mut original_table, new_table);
270+
*original_value = toml::Value::Table(original_table);
275271
}
276-
})
277-
.or_insert(new_value);
272+
_ => *original_value = new_value.clone(),
273+
}
274+
} else {
275+
original.insert(key, new_value);
276+
}
278277
}
279278
}
280279

@@ -368,8 +367,7 @@ fn merge_configuration_files(
368367
}
369368

370369
for (variable_name, variable_value) in package.variables {
371-
if let Some(first_value) = first_package.variables.get_mut(&variable_name).as_mut()
372-
{
370+
if let Some(first_value) = first_package.variables.get_mut(&variable_name) {
373371
match (first_value, variable_value) {
374372
(toml::Value::Table(first_value), toml::Value::Table(variable_value)) => {
375373
trace!("Merging {:?} tables", variable_name);
@@ -434,7 +432,7 @@ impl FileTarget {
434432

435433
pub fn set_path(&mut self, new_path: impl Into<PathBuf>) {
436434
match self {
437-
FileTarget::Automatic(ref mut path) => *path = new_path.into(),
435+
FileTarget::Automatic(path) => *path = new_path.into(),
438436
FileTarget::Symbolic(SymbolicTarget { target, .. })
439437
| FileTarget::ComplexTemplate(TemplateTarget { target, .. }) => {
440438
*target = new_path.into();

src/deploy.rs

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::actions::{self, ActionRunner, RealActionRunner};
99
use crate::args::Options;
1010
use crate::config::{self, Cache, FileTarget, SymbolicTarget, TemplateTarget};
1111
use crate::display_error;
12-
use crate::filesystem::{self, load_file, Filesystem};
12+
use crate::filesystem::{self, Filesystem, load_file};
1313
use crate::handlebars_helpers::create_new_handlebars;
1414
use crate::hooks;
1515

@@ -135,7 +135,9 @@ Proceeding by copying instead of symlinking."
135135
// === Post-deploy ===
136136

137137
if suggest_force {
138-
error!("Some files were skipped. To ignore errors and overwrite unexpected target files, use the --force flag.");
138+
error!(
139+
"Some files were skipped. To ignore errors and overwrite unexpected target files, use the --force flag."
140+
);
139141
error_occurred = true;
140142
}
141143

@@ -223,7 +225,9 @@ pub fn undeploy(opt: &Options) -> Result<bool> {
223225
// === Post-undeploy ===
224226

225227
if suggest_force {
226-
error!("Some files were skipped. To ignore errors and overwrite unexpected target files, use the --force flag.");
228+
error!(
229+
"Some files were skipped. To ignore errors and overwrite unexpected target files, use the --force flag."
230+
);
227231
error_occurred = true;
228232
}
229233

@@ -697,7 +701,7 @@ mod test {
697701

698702
let opt = Options::default();
699703
let handlebars = handlebars::Handlebars::new();
700-
let variables = BTreeMap::new();
704+
let variables = toml::map::Map::new();
701705

702706
// Expectation:
703707
// create_symlink
@@ -780,16 +784,20 @@ mod test {
780784
opt.force,
781785
opt.diff_context_lines,
782786
);
783-
assert!(runner
784-
.create_symlink(&PathBuf::from("a_in"), &PathBuf::from("a_out").into())
785-
.unwrap());
786-
assert!(runner
787-
.create_template(
788-
&PathBuf::from("b_in"),
789-
&PathBuf::from("cache/b_cache"),
790-
&PathBuf::from("b_out").into(),
791-
)
792-
.unwrap());
787+
assert!(
788+
runner
789+
.create_symlink(&PathBuf::from("a_in"), &PathBuf::from("a_out").into())
790+
.unwrap()
791+
);
792+
assert!(
793+
runner
794+
.create_template(
795+
&PathBuf::from("b_in"),
796+
&PathBuf::from("cache/b_cache"),
797+
&PathBuf::from("b_out").into(),
798+
)
799+
.unwrap()
800+
);
793801
}
794802

795803
#[test]
@@ -800,7 +808,7 @@ mod test {
800808

801809
let opt = Options::default();
802810
let handlebars = handlebars::Handlebars::new();
803-
let variables = BTreeMap::new();
811+
let variables = toml::map::Map::new();
804812

805813
// Expectation:
806814
// create_symlink
@@ -830,15 +838,19 @@ mod test {
830838
);
831839

832840
// Both should skip
833-
assert!(!runner
834-
.create_symlink(&PathBuf::from("a_in"), &PathBuf::from("a_out").into())
835-
.unwrap());
836-
assert!(!runner
837-
.create_template(
838-
&PathBuf::from("b_in"),
839-
&PathBuf::from("cache/b_cache"),
840-
&PathBuf::from("b_out").into(),
841-
)
842-
.unwrap());
841+
assert!(
842+
!runner
843+
.create_symlink(&PathBuf::from("a_in"), &PathBuf::from("a_out").into())
844+
.unwrap()
845+
);
846+
assert!(
847+
!runner
848+
.create_template(
849+
&PathBuf::from("b_in"),
850+
&PathBuf::from("cache/b_cache"),
851+
&PathBuf::from("b_out").into(),
852+
)
853+
.unwrap()
854+
);
843855
}
844856
}

src/filesystem.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ impl RealFilesystem {
248248
if !self.sudo_occurred {
249249
warn!("Elevating permissions ({})", goal.as_ref());
250250
if !log_enabled!(log::Level::Debug) {
251-
warn!("To see more than the first time elevated permissions are used, use verbosity 2 or more (-vv)");
251+
warn!(
252+
"To see more than the first time elevated permissions are used, use verbosity 2 or more (-vv)"
253+
);
252254
}
253255
self.sudo_occurred = true;
254256
} else {
@@ -825,7 +827,10 @@ pub fn is_template(source: &Path) -> Result<bool> {
825827
let mut buf = String::new();
826828

827829
if file.read_to_string(&mut buf).is_err() {
828-
warn!("File {:?} is not valid UTF-8 - detecting as symlink. Explicitly specify it to silence this message.", source);
830+
warn!(
831+
"File {:?} is not valid UTF-8 - detecting as symlink. Explicitly specify it to silence this message.",
832+
source
833+
);
829834
Ok(false)
830835
} else {
831836
Ok(buf.contains("{{"))

src/handlebars_helpers.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ mod test {
371371
fn eval_condition_simple() {
372372
let mut config = Configuration {
373373
files: Files::new(),
374-
variables: maplit::btreemap! { "foo".into() => 2.into() },
374+
variables: toml::map::Map::from_iter([("foo".into(), 2.into())]),
375375
#[cfg(feature = "scripting")]
376376
helpers: Helpers::new(),
377377
packages: maplit::btreemap! { "default".into() => true, "disabled".into() => false },
@@ -386,12 +386,14 @@ mod test {
386386
assert!(
387387
!eval_condition(&handlebars, &config.variables, "dotter.packages.nonexist").unwrap()
388388
);
389-
assert!(!eval_condition(
390-
&handlebars,
391-
&config.variables,
392-
"(and true dotter.packages.disabled)"
393-
)
394-
.unwrap());
389+
assert!(
390+
!eval_condition(
391+
&handlebars,
392+
&config.variables,
393+
"(and true dotter.packages.disabled)"
394+
)
395+
.unwrap()
396+
);
395397
}
396398

397399
#[test]
@@ -407,12 +409,14 @@ mod test {
407409
};
408410
let handlebars = create_new_handlebars(&mut config).unwrap();
409411

410-
assert!(!eval_condition(
411-
&handlebars,
412-
&config.variables,
413-
"(is_executable \"no_such_executable_please\")"
414-
)
415-
.unwrap());
412+
assert!(
413+
!eval_condition(
414+
&handlebars,
415+
&config.variables,
416+
"(is_executable \"no_such_executable_please\")"
417+
)
418+
.unwrap()
419+
);
416420
assert!(
417421
eval_condition(&handlebars, &config.variables, "(eq (math \"5+5\") \"10\")").unwrap()
418422
);

src/watch.rs

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::{Context, Result};
22
use watchexec::sources::fs::Watcher;
33
use watchexec::{Config, Watchexec};
4-
use watchexec_filterer_tagged::{Filter, Matcher, Op, Pattern, TaggedFilterer};
4+
use watchexec_filterer_globset::GlobsetFilterer;
55

66
use super::display_error;
77
use crate::args::Options;
@@ -13,41 +13,21 @@ pub(crate) async fn watch(opt: Options) -> Result<()> {
1313
config.file_watcher(Watcher::Native);
1414
config.pathset(["."]);
1515

16-
let filter = TaggedFilterer::new(".".into(), std::env::current_dir()?)
17-
.await
18-
.unwrap();
19-
filter
20-
.add_filters(&[
21-
Filter {
22-
in_path: None,
23-
on: Matcher::Path,
24-
op: Op::NotGlob,
25-
pat: Pattern::Glob(format!("{}/", opt.cache_directory.display())),
26-
negate: false,
27-
},
28-
Filter {
29-
in_path: None,
30-
on: Matcher::Path,
31-
op: Op::NotGlob,
32-
pat: Pattern::Glob(opt.cache_file.to_string_lossy().into()),
33-
negate: false,
34-
},
35-
Filter {
36-
in_path: None,
37-
on: Matcher::Path,
38-
op: Op::NotGlob,
39-
pat: Pattern::Glob(".git/".into()),
40-
negate: false,
41-
},
42-
Filter {
43-
in_path: None,
44-
on: Matcher::Path,
45-
op: Op::NotEqual,
46-
pat: Pattern::Exact("DOTTER_SYMLINK_TEST".into()),
47-
negate: false,
48-
},
49-
])
50-
.await?;
16+
let filter = GlobsetFilterer::new(
17+
std::env::current_dir()?,
18+
vec![
19+
(format!("!{}/", opt.cache_directory.display()), None),
20+
(format!("!{}", opt.cache_file.display()), None),
21+
("!.git/".to_string(), None),
22+
("!DOTTER_SYMLINK_TEST".to_string(), None),
23+
],
24+
vec![],
25+
vec![],
26+
vec![],
27+
vec![], // Add the 6th argument (extensions)
28+
)
29+
.await?;
30+
5131
config.filterer(filter);
5232

5333
config.on_action(move |mut action| {

0 commit comments

Comments
 (0)