summaryrefslogtreecommitdiffstats
path: root/src/feature
diff options
context:
space:
mode:
authorBen S <ogham@bsago.me>2015-05-12 03:33:40 +0100
committerBen S <ogham@bsago.me>2015-05-12 03:33:40 +0100
commit085067d18ed9004a2c6112def1f916a4b70084b5 (patch)
treebe99ba986564b881dafed40a87f4947782d906b8 /src/feature
parent2a3045ddfa976543e3336766bf82e60f3023561c (diff)
Move File fields to their own module
Diffstat (limited to 'src/feature')
-rw-r--r--src/feature/git.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/feature/git.rs b/src/feature/git.rs
index 1b58b65..59c3a8b 100644
--- a/src/feature/git.rs
+++ b/src/feature/git.rs
@@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
use git2;
-use file;
+use file::fields;
/// Container of Git statuses for all the files in this folder's Git repository.
pub struct Git {
@@ -28,48 +28,48 @@ impl Git {
}
/// Get the status for the file at the given path, if present.
- pub fn status(&self, path: &Path) -> file::Git {
+ pub fn status(&self, path: &Path) -> fields::Git {
let status = self.statuses.iter()
.find(|p| p.0.as_path() == path);
match status {
- Some(&(_, s)) => file::Git { staged: index_status(s), unstaged: working_tree_status(s) },
- None => file::Git { staged: file::GitStatus::NotModified, unstaged: file::GitStatus::NotModified }
+ Some(&(_, s)) => fields::Git { staged: index_status(s), unstaged: working_tree_status(s) },
+ None => fields::Git { staged: fields::GitStatus::NotModified, unstaged: fields::GitStatus::NotModified }
}
}
/// Get the combined status for all the files whose paths begin with the
/// path that gets passed in. This is used for getting the status of
/// directories, which don't really have an 'official' status.
- pub fn dir_status(&self, dir: &Path) -> file::Git {
+ pub fn dir_status(&self, dir: &Path) -> fields::Git {
let s = self.statuses.iter()
.filter(|p| p.0.starts_with(dir))
.fold(git2::Status::empty(), |a, b| a | b.1);
- file::Git { staged: index_status(s), unstaged: working_tree_status(s) }
+ fields::Git { staged: index_status(s), unstaged: working_tree_status(s) }
}
}
/// The character to display if the file has been modified, but not staged.
-fn working_tree_status(status: git2::Status) -> file::GitStatus {
+fn working_tree_status(status: git2::Status) -> fields::GitStatus {
match status {
- s if s.contains(git2::STATUS_WT_NEW) => file::GitStatus::New,
- s if s.contains(git2::STATUS_WT_MODIFIED) => file::GitStatus::Modified,
- s if s.contains(git2::STATUS_WT_DELETED) => file::GitStatus::Deleted,
- s if s.contains(git2::STATUS_WT_RENAMED) => file::GitStatus::Renamed,
- s if s.contains(git2::STATUS_WT_TYPECHANGE) => file::GitStatus::TypeChange,
- _ => file::GitStatus::NotModified,
+ s if s.contains(git2::STATUS_WT_NEW) => fields::GitStatus::New,
+ s if s.contains(git2::STATUS_WT_MODIFIED) => fields::GitStatus::Modified,
+ s if s.contains(git2::STATUS_WT_DELETED) => fields::GitStatus::Deleted,
+ s if s.contains(git2::STATUS_WT_RENAMED) => fields::GitStatus::Renamed,
+ s if s.contains(git2::STATUS_WT_TYPECHANGE) => fields::GitStatus::TypeChange,
+ _ => fields::GitStatus::NotModified,
}
}
/// The character to display if the file has been modified, and the change
/// has been staged.
-fn index_status(status: git2::Status) -> file::GitStatus {
+fn index_status(status: git2::Status) -> fields::GitStatus {
match status {
- s if s.contains(git2::STATUS_INDEX_NEW) => file::GitStatus::New,
- s if s.contains(git2::STATUS_INDEX_MODIFIED) => file::GitStatus::Modified,
- s if s.contains(git2::STATUS_INDEX_DELETED) => file::GitStatus::Deleted,
- s if s.contains(git2::STATUS_INDEX_RENAMED) => file::GitStatus::Renamed,
- s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => file::GitStatus::TypeChange,
- _ => file::GitStatus::NotModified,
+ s if s.contains(git2::STATUS_INDEX_NEW) => fields::GitStatus::New,
+ s if s.contains(git2::STATUS_INDEX_MODIFIED) => fields::GitStatus::Modified,
+ s if s.contains(git2::STATUS_INDEX_DELETED) => fields::GitStatus::Deleted,
+ s if s.contains(git2::STATUS_INDEX_RENAMED) => fields::GitStatus::Renamed,
+ s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => fields::GitStatus::TypeChange,
+ _ => fields::GitStatus::NotModified,
}
}