style: format the whole tree with cargo fmt (stock defaults, #35)
One-time, mechanical reformat — no functional changes. The tree was not rustfmt-clean (~1800 hunks across ~100 files); this brings it to stock `cargo fmt` defaults so a `cargo fmt --check` CI gate can follow. Behaviour-preserving: 2509 pass / 0 fail / 1 ignored (unchanged baseline), clippy clean. A .git-blame-ignore-revs entry follows so `git blame` skips this commit.
This commit is contained in:
+28
-29
@@ -78,10 +78,7 @@ pub fn read_last_project(data_root: &Path) -> std::io::Result<Option<PathBuf>> {
|
||||
/// a moved/deleted directory is the kind of error `--resume`
|
||||
/// is supposed to surface clearly, not paper over by
|
||||
/// resolving symlinks at write time.
|
||||
pub fn write_last_project(
|
||||
data_root: &Path,
|
||||
project_path: &Path,
|
||||
) -> std::io::Result<()> {
|
||||
pub fn write_last_project(data_root: &Path, project_path: &Path) -> std::io::Result<()> {
|
||||
fs::create_dir_all(data_root)?;
|
||||
let final_path = data_root.join(LAST_PROJECT_FILE);
|
||||
let tmp_path = data_root.join(format!("{LAST_PROJECT_FILE}.tmp"));
|
||||
@@ -108,9 +105,8 @@ pub fn resolve_data_root(override_dir: Option<&Path>) -> Result<PathBuf, Project
|
||||
if let Some(p) = override_dir {
|
||||
return Ok(p.to_path_buf());
|
||||
}
|
||||
let dirs = ProjectDirs::from("", "", "rdbms-playground").ok_or(
|
||||
ProjectError::DataRootUnavailable,
|
||||
)?;
|
||||
let dirs =
|
||||
ProjectDirs::from("", "", "rdbms-playground").ok_or(ProjectError::DataRootUnavailable)?;
|
||||
Ok(dirs.data_dir().to_path_buf())
|
||||
}
|
||||
|
||||
@@ -255,21 +251,16 @@ pub enum ProjectError {
|
||||
impl std::fmt::Display for ProjectError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::DataRootUnavailable => {
|
||||
f.write_str(&crate::t!("project.data_root_unavailable"))
|
||||
Self::DataRootUnavailable => f.write_str(&crate::t!("project.data_root_unavailable")),
|
||||
Self::PathNotFound(p) => {
|
||||
f.write_str(&crate::t!("project.path_not_found", path = p.display(),))
|
||||
}
|
||||
Self::NotAProject(p) => {
|
||||
f.write_str(&crate::t!("project.not_a_project", path = p.display(),))
|
||||
}
|
||||
Self::AlreadyExists(p) => {
|
||||
f.write_str(&crate::t!("project.already_exists", path = p.display(),))
|
||||
}
|
||||
Self::PathNotFound(p) => f.write_str(&crate::t!(
|
||||
"project.path_not_found",
|
||||
path = p.display(),
|
||||
)),
|
||||
Self::NotAProject(p) => f.write_str(&crate::t!(
|
||||
"project.not_a_project",
|
||||
path = p.display(),
|
||||
)),
|
||||
Self::AlreadyExists(p) => f.write_str(&crate::t!(
|
||||
"project.already_exists",
|
||||
path = p.display(),
|
||||
)),
|
||||
Self::Io { path, source } => f.write_str(&crate::t!(
|
||||
"project.io",
|
||||
path = path.display(),
|
||||
@@ -609,11 +600,10 @@ pub fn safely_delete_temp_project(
|
||||
// 2. Canonicalize for the containment check. We do this
|
||||
// only after the symlink-at-top check so we can't be
|
||||
// tricked by a top-level symlink.
|
||||
let project_canon =
|
||||
fs::canonicalize(project_path).map_err(|source| SafeDeleteError::Io {
|
||||
path: project_path.to_path_buf(),
|
||||
source,
|
||||
})?;
|
||||
let project_canon = fs::canonicalize(project_path).map_err(|source| SafeDeleteError::Io {
|
||||
path: project_path.to_path_buf(),
|
||||
source,
|
||||
})?;
|
||||
|
||||
// 3. Containment: canonical path must be inside the
|
||||
// canonical data-root projects dir.
|
||||
@@ -848,7 +838,10 @@ mod tests {
|
||||
assert!(gi.contains("/playground.db"));
|
||||
assert!(gi.contains("/.rdbms-playground.lock"));
|
||||
assert!(gi.contains("/.snapshots/"), "undo ring should be ignored");
|
||||
assert!(!gi.contains("history.log"), "history.log should NOT be ignored");
|
||||
assert!(
|
||||
!gi.contains("history.log"),
|
||||
"history.log should NOT be ignored"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -890,7 +883,10 @@ mod tests {
|
||||
let target = tmp.path().join("MyProject");
|
||||
fs::create_dir(&target).unwrap();
|
||||
let err = Project::create_named(&target).expect_err("must refuse");
|
||||
assert!(matches!(err, ProjectError::AlreadyExists(_)), "got: {err:?}");
|
||||
assert!(
|
||||
matches!(err, ProjectError::AlreadyExists(_)),
|
||||
"got: {err:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -962,7 +958,10 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let read_back = read_last_project(tmp.path()).unwrap();
|
||||
assert_eq!(read_back, Some(std::path::PathBuf::from("/tmp/some/project")));
|
||||
assert_eq!(
|
||||
read_back,
|
||||
Some(std::path::PathBuf::from("/tmp/some/project"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user