mirror of
https://github.com/starship/starship.git
synced 2024-12-15 20:00:45 +01:00
Merge branch 'master' into conditional-style
This commit is contained in:
commit
2295d92c1b
@ -23,7 +23,7 @@ license = "ISC"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/starship/starship"
|
repository = "https://github.com/starship/starship"
|
||||||
# Note: MSRV is only intended as a hint, and only the latest version is officially supported in starship.
|
# Note: MSRV is only intended as a hint, and only the latest version is officially supported in starship.
|
||||||
rust-version = "1.60"
|
rust-version = "1.64"
|
||||||
description = """
|
description = """
|
||||||
The minimal, blazing-fast, and infinitely customizable prompt for any shell! ☄🌌️
|
The minimal, blazing-fast, and infinitely customizable prompt for any shell! ☄🌌️
|
||||||
"""
|
"""
|
||||||
|
@ -102,11 +102,19 @@ fn get_setup_cfg_version(context: &Context, config: &PackageConfig) -> Option<St
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_gradle_version(context: &Context, config: &PackageConfig) -> Option<String> {
|
fn get_gradle_version(context: &Context, config: &PackageConfig) -> Option<String> {
|
||||||
let file_contents = context.read_file_from_pwd("build.gradle")?;
|
context
|
||||||
let re = Regex::new(r#"(?m)^version ['"](?P<version>[^'"]+)['"]$"#).unwrap();
|
.read_file_from_pwd("gradle.properties")
|
||||||
let caps = re.captures(&file_contents)?;
|
.and_then(|contents| {
|
||||||
|
let re = Regex::new(r"version=(?P<version>.*)").unwrap();
|
||||||
|
let caps = re.captures(&contents)?;
|
||||||
|
format_version(&caps["version"], config.version_format)
|
||||||
|
}).or_else(|| {
|
||||||
|
let build_file_contents = context.read_file_from_pwd("build.gradle")?;
|
||||||
|
let re = Regex::new(r#"(?m)^version ['"](?P<version>[^'"]+)['"]$"#).unwrap(); /*dark magic*/
|
||||||
|
let caps = re.captures(&build_file_contents)?;
|
||||||
|
format_version(&caps["version"], config.version_format)
|
||||||
|
|
||||||
format_version(&caps["version"], config.version_format)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_composer_version(context: &Context, config: &PackageConfig) -> Option<String> {
|
fn get_composer_version(context: &Context, config: &PackageConfig) -> Option<String> {
|
||||||
@ -960,6 +968,17 @@ java {
|
|||||||
expect_output(&project_dir, None, None);
|
expect_output(&project_dir, None, None);
|
||||||
project_dir.close()
|
project_dir.close()
|
||||||
}
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_extract_grade_version_from_properties() -> io::Result<()> {
|
||||||
|
let config_name = "gradle.properties";
|
||||||
|
let config_content = "
|
||||||
|
version=1.2.3
|
||||||
|
";
|
||||||
|
let project_dir = create_project_dir()?;
|
||||||
|
fill_config(&project_dir, config_name, Some(config_content))?;
|
||||||
|
expect_output(&project_dir, Some("v1.2.3"), None);
|
||||||
|
project_dir.close()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_extract_mix_version() -> io::Result<()> {
|
fn test_extract_mix_version() -> io::Result<()> {
|
||||||
|
@ -136,7 +136,7 @@ impl<'de> Deserializer<'de> for ValueDeserializer<'de> {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter_map(|field| {
|
.filter_map(|field| {
|
||||||
let score = strsim::jaro_winkler(key, field);
|
let score = strsim::jaro_winkler(key, field);
|
||||||
(score > 0.8).then(|| (score, field))
|
(score > 0.8).then_some((score, field))
|
||||||
})
|
})
|
||||||
.max_by(|(score_a, _field_a), (score_b, _field_b)| {
|
.max_by(|(score_a, _field_a), (score_b, _field_b)| {
|
||||||
score_a.partial_cmp(score_b).unwrap_or(Ordering::Equal)
|
score_a.partial_cmp(score_b).unwrap_or(Ordering::Equal)
|
||||||
|
Loading…
Reference in New Issue
Block a user