aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-05-20 14:05:32 +0100
committerNerdyPepper <[email protected]>2019-05-20 14:05:32 +0100
commit9a5623a79523f5727c096870d98e2f8112d395ed (patch)
treebad8c7843285736698df9f8b98730d443a9f6c9c /src
parentf982aa673701bd5084a228ce9caee6941e3d86f1 (diff)
fixed: status does not display in subdirectories
Diffstat (limited to 'src')
-rw-r--r--src/vcs.rs23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/vcs.rs b/src/vcs.rs
index db69897..eddc83c 100644
--- a/src/vcs.rs
+++ b/src/vcs.rs
@@ -1,15 +1,26 @@
1use std::env; 1use std::env;
2use std::path::Path;
2use git2::{ Repository, Status }; 3use git2::{ Repository, Status };
3use colored::*; 4use colored::*;
4 5
5pub fn vcs_status() -> Option<(colored::ColoredString, colored::ColoredString)> { 6pub fn vcs_status() -> Option<(colored::ColoredString, colored::ColoredString)> {
6 let current_dir = env::var("PWD").unwrap(); 7 let current_dir = env::var("PWD").unwrap();
7 8
8 let repo = match Repository::open(current_dir) { 9 let mut repo: Option<Repository> = None;
9 Ok(r) => r, 10 let current_path = Path::new(&current_dir[..]);
10 Err(_) => return None 11 for path in current_path.ancestors() {
11 }; 12 match Repository::open(path) {
12 13 Ok(r) => {
14 repo = Some(r);
15 break;
16 }
17 Err(_) => {},
18 }
19 }
20 if repo.is_none() {
21 return None
22 }
23 let repo = repo.unwrap();
13 let reference = repo.head().unwrap(); 24 let reference = repo.head().unwrap();
14 let mut branch; 25 let mut branch;
15 26