aboutsummaryrefslogtreecommitdiff
path: root/src/actions
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/create.rs21
-rw-r--r--src/actions/update.rs4
2 files changed, 16 insertions, 9 deletions
diff --git a/src/actions/create.rs b/src/actions/create.rs
index 2b664b3..c89c3c9 100644
--- a/src/actions/create.rs
+++ b/src/actions/create.rs
@@ -26,7 +26,14 @@ pub fn create(command_options: ActionOptions, fs: &impl Fs, timestamp: u64) -> R
mod tests {
use std::path::Path;
- use crate::{actions::ActionOptions, diff::ContentChange, filesystem::mock::{EntryMock, FsMock, FsState}, history::{FileChange, FileChangeVariant, FileHistory, RepositoryChange, RepositoryHistory}};
+ use crate::{
+ actions::ActionOptions,
+ diff::ContentChange,
+ filesystem::mock::{EntryMock, FsMock, FsState},
+ history::{
+ FileChange, FileChangeVariant, FileHistory, RepositoryChange, RepositoryHistory,
+ },
+ };
use super::create;
@@ -37,7 +44,7 @@ mod tests {
let options = ActionOptions::from_path(".");
let expected_index = RepositoryHistory::default().encode().unwrap();
-
+
create(options, &fs_mock, now).expect("Action failed.");
fs_mock.assert_match(FsState::new(vec![
@@ -76,19 +83,19 @@ mod tests {
history.encode().unwrap()
};
- fs_mock.set_state(FsState::new(vec![
- EntryMock::file("./test", &vec![1, 2, 3])
- ]));
+ fs_mock.set_state(FsState::new(vec![EntryMock::file(
+ "./test",
+ &vec![1, 2, 3],
+ )]));
create(options, &fs_mock, now).expect("Action failed.");
fs_mock.assert_match(FsState::new(vec![
EntryMock::file("./test", &vec![1, 2, 3]),
-
EntryMock::dir("./.ka"),
EntryMock::file("./.ka/index", &expected_index),
EntryMock::dir("./.ka/files"),
EntryMock::file("./.ka/files/test", &expected_file_history),
]))
}
-} \ No newline at end of file
+}
diff --git a/src/actions/update.rs b/src/actions/update.rs
index 05379c1..081be72 100644
--- a/src/actions/update.rs
+++ b/src/actions/update.rs
@@ -97,13 +97,13 @@ fn get_new_history_for_file<FS: Fs>(
let changes = ContentChange::diff(&old_content, &new_content);
- if !changes.is_empty() {
+ if !changes.is_empty() {
let mut new_history = file_history;
new_history.add_change(FileChange {
change_index: cursor + 1,
variant: FileChangeVariant::Updated(changes),
});
-
+
Ok(Some((history_file, new_history)))
} else {
Ok(None)