1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-12-04 02:48:25 +00:00

fix(package): support alternative gradle module version syntax (#6080)

feat(package): support alternative gradle module version syntax (#6079)
This commit is contained in:
JKatzwinkel 2024-07-29 22:19:56 +02:00 committed by GitHub
parent 274dff37db
commit a62012e328
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,7 +110,7 @@ fn get_gradle_version(context: &Context, config: &PackageConfig) -> Option<Strin
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 re = Regex::new(r#"(?m)^version( |\s*=\s*)['"](?P<version>[^'"]+)['"]$"#).unwrap(); /*dark magic*/
let caps = re.captures(&build_file_contents)?;
format_version(&caps["version"], config.version_format)
@ -921,6 +921,25 @@ java {
project_dir.close()
}
#[test]
fn test_extract_gradle_version_setter_notation_single_quote() -> io::Result<()> {
let config_name = "build.gradle";
let config_content = "plugins {
id 'java'
id 'test.plugin' version '0.2.0'
}
version = '0.1.0'
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}";
let project_dir = create_project_dir()?;
fill_config(&project_dir, config_name, Some(config_content))?;
expect_output(&project_dir, Some("v0.1.0"), None);
project_dir.close()
}
#[test]
fn test_extract_gradle_version_double_quote() -> io::Result<()> {
let config_name = "build.gradle";