mirror of
https://github.com/Llewellynvdm/starship.git
synced 2025-01-24 23:58:28 +00:00
fix(python): Trim "Anaconda, Inc." from version (#861)
This commit is contained in:
parent
57427b5d7a
commit
b723a7d562
@ -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");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user