diff options
author | Ben S <ogham@bsago.me> | 2015-01-27 15:30:55 +0000 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-01-27 15:30:55 +0000 |
commit | 1d0cc329eb4a6c9aa26c9c2b3ef3c486a1eaf7da (patch) | |
tree | 2d49bf65382b4b2499cc13b6a1b4a48c01153122 /src/dir.rs | |
parent | 90d4684de4d64fadcd4025c2c86e5c82857f6cd0 (diff) |
Don't even show the column without the feature
Diffstat (limited to 'src/dir.rs')
-rw-r--r-- | src/dir.rs | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -25,7 +25,7 @@ impl Dir { fs::readdir(&path).map(|paths| Dir { contents: paths, path: path.clone(), - git: Git::new(&path).ok(), + git: Git::scan(&path).ok(), }) } @@ -68,6 +68,7 @@ impl Dir { } } +/// Container of Git statuses for all the files in this folder's Git repository. #[cfg(feature="git")] struct Git { statuses: Vec<(String, git2::Status)>, @@ -75,7 +76,10 @@ struct Git { #[cfg(feature="git")] impl Git { - fn new(path: &Path) -> Result<Git, git2::Error> { + + /// Discover a Git repository on or above this directory, scanning it for + /// the files' statuses if one is found. + fn scan(path: &Path) -> Result<Git, git2::Error> { let repo = try!(git2::Repository::discover(path)); let statuses = try!(repo.statuses(None)); @@ -121,11 +125,13 @@ struct Git; #[cfg(not(feature="git"))] impl Git { - fn new(_: &Path) -> Result<Git, ()> { + fn scan(_: &Path) -> Result<Git, ()> { + // Don't do anything without Git support Err(()) } fn status(&self, _: &Path) -> String { + // The Err above means that this should never happen panic!("Tried to access a Git repo without Git support!"); } } |