1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-28 07:46:28 +00:00

perf(directory): Skip repo resolution if unused by directory config (#4401)

Skip repo resolution if its not used by directory config
This commit is contained in:
Robert Edwards 2022-10-06 03:33:31 -04:00 committed by GitHub
parent 03c4165927
commit 227ec32d9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,11 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
// Attempt repository path contraction (if we are in a git repository)
// Otherwise use the logical path, automatically contracting
let repo = context.get_repo().ok();
let repo = if config.truncate_to_repo || config.repo_root_style.is_some() {
context.get_repo().ok()
} else {
None
};
let dir_string = if config.truncate_to_repo {
repo.and_then(|r| r.workdir.as_ref())
.filter(|&root| root != &home_dir)