summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-05-09 23:51:50 -0400
committerGitHub <noreply@github.com>2019-05-09 23:51:50 -0400
commit8b5055d5106da402f9a132f0ed21571ef98b8ac2 (patch)
treed5d83454742235f44b183b932355189983ba074c /src/modules
parentc6ee5c6ac16d360ab1a44d097c91fe9f98f20f85 (diff)
Parallelize prompt modules (#46)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/directory.rs3
-rw-r--r--src/modules/git_branch.rs8
2 files changed, 4 insertions, 7 deletions
diff --git a/src/modules/directory.rs b/src/modules/directory.rs
index a85287a67..e0f4a9e12 100644
--- a/src/modules/directory.rs
+++ b/src/modules/directory.rs
@@ -23,9 +23,8 @@ pub fn segment(context: &Context) -> Option<Module> {
let current_dir = &context.current_dir;
let dir_string;
- if let Some(repo) = &context.repository {
+ if let Some(repo_root) = &context.repo_root {
// Contract the path to the git repo root
- let repo_root = repo.workdir().unwrap();
let repo_folder_name = repo_root.file_name().unwrap().to_str().unwrap();
dir_string = contract_path(&current_dir, repo_root, repo_folder_name);
diff --git a/src/modules/git_branch.rs b/src/modules/git_branch.rs
index a89e77f3e..22b934da3 100644
--- a/src/modules/git_branch.rs
+++ b/src/modules/git_branch.rs
@@ -7,12 +7,10 @@ use super::{Context, Module};
///
/// Will display the branch name if the current directory is a git repo
pub fn segment(context: &Context) -> Option<Module> {
- if context.repository.is_none() {
- return None;
- }
+ let repo_root = context.repo_root.as_ref()?;
+ let repository = Repository::open(repo_root).ok()?;
- let repository = context.repository.as_ref().unwrap();
- match get_current_branch(repository) {
+ match get_current_branch(&repository) {
Ok(branch_name) => {
const GIT_BRANCH_CHAR: &str = " ";
let segment_color = Color::Purple.bold();