summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-04-09 00:04:50 -0400
committerMatan Kushner <hello@matchai.me>2019-04-09 00:04:50 -0400
commit67ab2121c578a59c076269597d1f2fcf71af2f57 (patch)
tree9d4d163e3da2aa791317caf96a68d91da8d05822 /src
parent969840a15709b1ede088fdfc54aa53f032993c45 (diff)
Add note and test regarding paths being physical
Diffstat (limited to 'src')
-rw-r--r--src/modules/directory.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/modules/directory.rs b/src/modules/directory.rs
index edbdc1f6a..f7a95584f 100644
--- a/src/modules/directory.rs
+++ b/src/modules/directory.rs
@@ -20,10 +20,9 @@ pub fn segment(_: &ArgMatches) -> Segment {
const DIR_TRUNCATION_LENGTH: usize = 3;
const HOME_SYMBOL: &str = "~";
+ // TODO: Currently gets the physical directory. Get the logical directory.
let current_path = env::current_dir()
- .expect("Unable to identify current directory")
- .canonicalize()
- .expect("Unable to canonicalize current directory");
+ .expect("Unable to identify current directory");
let dir_string;
if let Ok(repo) = git2::Repository::discover(&current_path) {
@@ -138,4 +137,17 @@ mod tests {
let segment = segment(&args);
assert_eq!(segment.value, "/");
}
+
+ #[test]
+ fn do_not_canonicalize_paths() {
+ let args = App::new("starship")
+ .arg(Arg::with_name("status_code"))
+ .get_matches_from(vec!["starship", "0"]);
+
+ let root_dir = Path::new("/var");
+ env::set_current_dir(&root_dir).unwrap();
+
+ let segment = segment(&args);
+ assert_eq!(segment.value, "/var");
+ }
}