From b86138b138565178b916b24d1e30d5786fd9d1c5 Mon Sep 17 00:00:00 2001 From: Mel Date: Tue, 21 Sep 2021 13:46:03 +0200 Subject: More consistent naming --- src/actions/update.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/actions/update.rs') diff --git a/src/actions/update.rs b/src/actions/update.rs index a7d1aad..73a9222 100644 --- a/src/actions/update.rs +++ b/src/actions/update.rs @@ -3,7 +3,7 @@ use std::io::Read; use anyhow::{Context, Result}; use crate::{ - files::{Locations, RepositoryPaths}, + files::{Locations, FileState}, history::{FileChange, FileHistory}, text_diff::TextChange, }; @@ -14,7 +14,7 @@ pub fn update(command_options: ActionOptions) -> Result<()> { let locations = Locations::from(&command_options); let entries = locations - .get_repository_paths() + .get_repository_files() .context("Could not traverse files.")?; for element in entries { @@ -24,9 +24,9 @@ pub fn update(command_options: ActionOptions) -> Result<()> { Ok(()) } -fn update_file(paths: RepositoryPaths, locations: &Locations) -> Result<()> { - let new_state = match paths { - RepositoryPaths::Deleted(deleted) => { +fn update_file(file_state: FileState, locations: &Locations) -> Result<()> { + let new_state = match file_state { + FileState::Deleted(deleted) => { let mut history_file = deleted.load_history_file()?; let file_history = FileHistory::from_file(&mut history_file)?; if !file_history.file_is_deleted() { @@ -37,7 +37,7 @@ fn update_file(paths: RepositoryPaths, locations: &Locations) -> Result<()> { None } } - RepositoryPaths::Untracked(untracked) => { + FileState::Untracked(untracked) => { let mut file = untracked.load_file()?; let mut file_content = String::new(); @@ -53,14 +53,14 @@ fn update_file(paths: RepositoryPaths, locations: &Locations) -> Result<()> { Some((untracked.create_history_file(locations)?, new_history)) } - RepositoryPaths::Tracked(tracked) => { + FileState::Tracked(tracked) => { let mut history_file = tracked.load_history_file()?; - let mut tracked_file = tracked.load_tracked_file()?; + let mut working_file = tracked.load_working_file()?; let file_history = FileHistory::from_file(&mut history_file)?; let mut new_content = String::new(); - tracked_file.read_to_string(&mut new_content)?; + working_file.read_to_string(&mut new_content)?; let old_content = file_history.get_content(); -- cgit 1.4.1