Add the Git branch segment (#32)

Added
- Repository to Context for reuse in directory and git_branch
- git_branch to prompt

Changed
- Made segments bold to match spaceship
This commit is contained in:
Matan Kushner
2019-04-26 22:07:07 -04:00
committed by GitHub
parent 85e4b11f0b
commit 9a352c0acc
8 changed files with 62 additions and 20 deletions
+6 -1
View File
@@ -1,4 +1,5 @@
use clap::ArgMatches;
use git2::Repository;
use std::env;
use std::fs;
use std::path::PathBuf;
@@ -7,6 +8,7 @@ pub struct Context<'a> {
pub current_dir: PathBuf,
pub dir_files: Vec<PathBuf>,
pub arguments: ArgMatches<'a>,
pub repository: Option<Repository>,
}
impl<'a> Context<'a> {
@@ -34,10 +36,13 @@ impl<'a> Context<'a> {
.map(|entry| entry.path())
.collect::<Vec<PathBuf>>();
let repository: Option<Repository> = Repository::discover(&current_dir).ok();
Context {
current_dir,
arguments,
current_dir,
dir_files,
repository,
}
}