Skip to content

Commit 313e9a6

Browse files
committed
Fix CI fmt/clippy failures on master
Apply rustfmt changes and resolve clippy -D warnings (collapsible_if in expand_tilde) so the CI workflow commands pass: cargo fmt --check, cargo clippy -- -D warnings, and cargo test.
1 parent f2e6b58 commit 313e9a6

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

src/main.rs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ fn merge_toml_values(dst: &mut toml::Value, src: toml::Value) {
256256

257257
/// Expand a leading `~/` or lone `~` using the `HOME` env var.
258258
fn expand_tilde(path: &str) -> PathBuf {
259-
if let Some(rest) = path.strip_prefix("~/") {
260-
if let Some(home) = std::env::var_os("HOME") {
261-
return PathBuf::from(home).join(rest);
262-
}
259+
if let Some(rest) = path.strip_prefix("~/")
260+
&& let Some(home) = std::env::var_os("HOME")
261+
{
262+
return PathBuf::from(home).join(rest);
263263
}
264-
if path == "~" {
265-
if let Some(home) = std::env::var_os("HOME") {
266-
return PathBuf::from(home);
267-
}
264+
if path == "~"
265+
&& let Some(home) = std::env::var_os("HOME")
266+
{
267+
return PathBuf::from(home);
268268
}
269269
PathBuf::from(path)
270270
}
@@ -386,7 +386,10 @@ fn cmd_ensure_branch(branch: &str, config: &Config) -> Result<()> {
386386
}
387387

388388
if fetch_attempted {
389-
bail!("branch '{}' does not exist locally and was not found on the remote", branch);
389+
bail!(
390+
"branch '{}' does not exist locally and was not found on the remote",
391+
branch
392+
);
390393
}
391394
bail!(
392395
"branch '{}' does not exist locally. Hint: add `on_missing_branch = \"fetch, create\"` to your terris config",
@@ -470,7 +473,14 @@ fn create_worktree_from_remote(root: &Path, branch: &str, path: &Path) -> Result
470473
let remote_ref = format!("origin/{}", branch);
471474
run_git_silence_stdout(
472475
[
473-
"worktree", "add", "--quiet", "--track", "-b", branch, &path_str, &remote_ref,
476+
"worktree",
477+
"add",
478+
"--quiet",
479+
"--track",
480+
"-b",
481+
branch,
482+
&path_str,
483+
&remote_ref,
474484
],
475485
root,
476486
)
@@ -993,27 +1003,23 @@ prunable stale
9931003

9941004
#[test]
9951005
fn missing_branch_strategy_rejects_invalid_combinations() {
996-
let with_error =
997-
toml::from_str::<BehaviorConfig>("on_missing_branch = \"error, fetch\"");
1006+
let with_error = toml::from_str::<BehaviorConfig>("on_missing_branch = \"error, fetch\"");
9981007
assert!(with_error.is_err());
9991008

10001009
let with_duplicate =
10011010
toml::from_str::<BehaviorConfig>("on_missing_branch = \"fetch, fetch\"");
10021011
assert!(with_duplicate.is_err());
10031012

1004-
let with_empty =
1005-
toml::from_str::<BehaviorConfig>("on_missing_branch = \"fetch, \"");
1013+
let with_empty = toml::from_str::<BehaviorConfig>("on_missing_branch = \"fetch, \"");
10061014
assert!(with_empty.is_err());
10071015

1008-
let result =
1009-
toml::from_str::<BehaviorConfig>("on_missing_branch = \"teleport\"");
1016+
let result = toml::from_str::<BehaviorConfig>("on_missing_branch = \"teleport\"");
10101017
assert!(result.is_err());
10111018
}
10121019

10131020
#[test]
10141021
fn merge_toml_values_layers_global_and_local() {
1015-
let mut merged: toml::Value =
1016-
toml::from_str("[display]\nshow_head = true\n").unwrap();
1022+
let mut merged: toml::Value = toml::from_str("[display]\nshow_head = true\n").unwrap();
10171023
let local: toml::Value = toml::from_str(
10181024
"[worktrees]\nuse_random_suffix = false\n[display]\nshow_head = false\n",
10191025
)
@@ -1049,8 +1055,9 @@ prunable stale
10491055
},
10501056
..Config::default()
10511057
};
1052-
let err =
1053-
default_worktree_path("repo", "branch", &config).unwrap_err().to_string();
1058+
let err = default_worktree_path("repo", "branch", &config)
1059+
.unwrap_err()
1060+
.to_string();
10541061
assert!(err.contains("worktrees.suffix_length"));
10551062
}
10561063
}

0 commit comments

Comments
 (0)