Skip to content

Commit

Permalink
fix(package): fix meson version extraction if 'meson_version' is pres…
Browse files Browse the repository at this point in the history
…ent (starship#2397)
  • Loading branch information
EHfive authored Mar 12, 2021
1 parent a2e7f69 commit 8f46dff
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/modules/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn extract_maven_version(file_contents: &str) -> Option<String> {
fn extract_meson_version(file_contents: &str) -> Option<String> {
let file_contents = file_contents.split_ascii_whitespace().collect::<String>();

let re = Regex::new(r#"project\([^())]*version:'(?P<version>[^']+)'[^())]*\)"#).unwrap();
let re = Regex::new(r#"project\([^())]*,version:'(?P<version>[^']+)'[^())]*\)"#).unwrap();
let caps = re.captures(&file_contents)?;

let formatted_version = format_version(&caps["version"]);
Expand Down Expand Up @@ -756,6 +756,18 @@ end";
project_dir.close()
}

#[test]
fn test_extract_meson_version_with_meson_version() -> io::Result<()> {
let config_name = "meson.build";
let config_content =
"project('starship', 'rust', version: '0.1.0', meson_version: '>= 0.57.0')".to_string();

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()
}

fn create_project_dir() -> io::Result<TempDir> {
tempfile::tempdir()
}
Expand Down

0 comments on commit 8f46dff

Please sign in to comment.