refactor: apply rustfmt formatting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Test
2026-03-06 15:43:43 +01:00
parent 6f6e7d7cfe
commit eb55c5ec02
5 changed files with 46 additions and 26 deletions

View File

@@ -274,11 +274,23 @@ mod tests {
init_repo(vault.to_str().unwrap()).unwrap();
let gitignore = vault.join(".gitignore");
assert!(gitignore.exists(), ".gitignore should be created by init_repo");
assert!(
gitignore.exists(),
".gitignore should be created by init_repo"
);
let content = fs::read_to_string(&gitignore).unwrap();
assert!(content.contains(".DS_Store"), ".gitignore should exclude .DS_Store");
assert!(content.contains(".laputa-cache.json"), ".gitignore should exclude .laputa-cache.json");
assert!(content.contains(".laputa/settings.json"), ".gitignore should exclude settings.json");
assert!(
content.contains(".DS_Store"),
".gitignore should exclude .DS_Store"
);
assert!(
content.contains(".laputa-cache.json"),
".gitignore should exclude .laputa-cache.json"
);
assert!(
content.contains(".laputa/settings.json"),
".gitignore should exclude settings.json"
);
}
#[test]
@@ -292,7 +304,10 @@ mod tests {
init_repo(vault.to_str().unwrap()).unwrap();
let content = fs::read_to_string(vault.join(".gitignore")).unwrap();
assert_eq!(content, "custom-rule\n", "existing .gitignore should not be overwritten");
assert_eq!(
content, "custom-rule\n",
"existing .gitignore should not be overwritten"
);
}
#[test]

View File

@@ -10,8 +10,8 @@ use std::path::Path;
pub use create::{create_theme, create_vault_theme};
pub use defaults::*;
pub use seed::{
ensure_theme_type_definition, ensure_vault_themes, restore_default_themes,
seed_default_themes, seed_vault_themes,
ensure_theme_type_definition, ensure_vault_themes, restore_default_themes, seed_default_themes,
seed_vault_themes,
};
/// A theme file parsed from _themes/*.json in the vault.

View File

@@ -113,8 +113,7 @@ pub fn restore_default_themes(vault_path: &str) -> Result<String, String> {
/// Create `type/theme.md` if it doesn't exist (gives the Theme type a sidebar icon/color).
pub fn ensure_theme_type_definition(vault_path: &str) -> Result<(), String> {
let type_dir = Path::new(vault_path).join("type");
fs::create_dir_all(&type_dir)
.map_err(|e| format!("Failed to create type directory: {e}"))?;
fs::create_dir_all(&type_dir).map_err(|e| format!("Failed to create type directory: {e}"))?;
let path = type_dir.join("theme.md");
let needs_write = !path.exists() || fs::metadata(&path).map_or(true, |m| m.len() == 0);
if needs_write {

View File

@@ -100,17 +100,14 @@ fn git_uncommitted_files(vault: &Path) -> Vec<String> {
// Untracked files via ls-files (lists individual files, not just directories).
// git status --porcelain shows `?? dir/` for new directories, hiding individual
// files inside — ls-files resolves them so the cache picks up all new .md files.
let untracked = run_git(
vault,
&["ls-files", "--others", "--exclude-standard"],
)
.map(|s| {
s.lines()
.filter(|l| !l.is_empty() && l.ends_with(".md"))
.map(|l| l.to_string())
.collect::<Vec<_>>()
})
.unwrap_or_default();
let untracked = run_git(vault, &["ls-files", "--others", "--exclude-standard"])
.map(|s| {
s.lines()
.filter(|l| !l.is_empty() && l.ends_with(".md"))
.map(|l| l.to_string())
.collect::<Vec<_>>()
})
.unwrap_or_default();
for path in untracked {
if !files.contains(&path) {

View File

@@ -412,12 +412,21 @@ pub fn create_getting_started_vault(target_path: &str) -> Result<String, String>
let theme_notes_dir = vault_dir.join("theme");
fs::create_dir_all(&theme_notes_dir)
.map_err(|e| format!("Failed to create theme directory: {e}"))?;
fs::write(theme_notes_dir.join("default.md"), crate::theme::DEFAULT_VAULT_THEME)
.map_err(|e| format!("Failed to write default vault theme: {e}"))?;
fs::write(theme_notes_dir.join("dark.md"), crate::theme::DARK_VAULT_THEME)
.map_err(|e| format!("Failed to write dark vault theme: {e}"))?;
fs::write(theme_notes_dir.join("minimal.md"), crate::theme::MINIMAL_VAULT_THEME)
.map_err(|e| format!("Failed to write minimal vault theme: {e}"))?;
fs::write(
theme_notes_dir.join("default.md"),
crate::theme::DEFAULT_VAULT_THEME,
)
.map_err(|e| format!("Failed to write default vault theme: {e}"))?;
fs::write(
theme_notes_dir.join("dark.md"),
crate::theme::DARK_VAULT_THEME,
)
.map_err(|e| format!("Failed to write dark vault theme: {e}"))?;
fs::write(
theme_notes_dir.join("minimal.md"),
crate::theme::MINIMAL_VAULT_THEME,
)
.map_err(|e| format!("Failed to write minimal vault theme: {e}"))?;
crate::git::init_repo(target_path)?;