1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-09-28 21:19:10 +00:00

fix(python): Trim "Anaconda, Inc." from version (#861)

This commit is contained in:
Peter Bull 2020-01-21 08:14:40 -08:00 committed by Matan Kushner
parent 57427b5d7a
commit b723a7d562

View File

@ -73,7 +73,13 @@ fn get_python_version() -> Option<String> {
}
fn format_python_version(python_stdout: &str) -> String {
format!("v{}", python_stdout.trim_start_matches("Python ").trim())
format!(
"v{}",
python_stdout
.trim_start_matches("Python ")
.trim_end_matches(":: Anaconda, Inc.")
.trim()
)
}
fn get_python_virtual_env() -> Option<String> {
@ -93,4 +99,10 @@ mod tests {
let input = "Python 3.7.2";
assert_eq!(format_python_version(input), "v3.7.2");
}
#[test]
fn test_format_python_version_anaconda() {
let input = "Python 3.6.10 :: Anaconda, Inc.";
assert_eq!(format_python_version(input), "v3.6.10");
}
}