fix(package): Improve regex for extracting gradle version from gradle.properties (#4760)
fix: Improve regex for extracting gradle package version from gradle.properties (#4759)
This commit is contained in:
parent
d4e664eda5
commit
9093891acb
|
@ -105,7 +105,7 @@ fn get_gradle_version(context: &Context, config: &PackageConfig) -> Option<Strin
|
||||||
context
|
context
|
||||||
.read_file_from_pwd("gradle.properties")
|
.read_file_from_pwd("gradle.properties")
|
||||||
.and_then(|contents| {
|
.and_then(|contents| {
|
||||||
let re = Regex::new(r"version=(?P<version>.*)").unwrap();
|
let re = Regex::new(r"(?m)^\s*version\s*=\s*(?P<version>.*)").unwrap();
|
||||||
let caps = re.captures(&contents)?;
|
let caps = re.captures(&contents)?;
|
||||||
format_version(&caps["version"], config.version_format)
|
format_version(&caps["version"], config.version_format)
|
||||||
}).or_else(|| {
|
}).or_else(|| {
|
||||||
|
@ -979,6 +979,18 @@ java {
|
||||||
expect_output(&project_dir, Some("v1.2.3"), None);
|
expect_output(&project_dir, Some("v1.2.3"), None);
|
||||||
project_dir.close()
|
project_dir.close()
|
||||||
}
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_extract_grade_version_from_properties_with_comment_and_whitespace() -> io::Result<()> {
|
||||||
|
let config_name = "gradle.properties";
|
||||||
|
let config_content = "
|
||||||
|
# or use -Pversion=0.0.1
|
||||||
|
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<()> {
|
||||||
|
|
Loading…
Reference in New Issue