feat: abbreviate package.json semantic versions (#2271)
This commit is contained in:
parent
8a8dca71a6
commit
c2e84e1802
|
@ -68,6 +68,11 @@ fn extract_package_version(file_contents: &str, display_private: bool) -> Option
|
||||||
};
|
};
|
||||||
|
|
||||||
let formatted_version = format_version(raw_version);
|
let formatted_version = format_version(raw_version);
|
||||||
|
if formatted_version == "v0.0.0-development" || formatted_version.starts_with("v0.0.0-semantic")
|
||||||
|
{
|
||||||
|
return Some("semantic".to_string());
|
||||||
|
};
|
||||||
|
|
||||||
Some(formatted_version)
|
Some(formatted_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,6 +348,51 @@ mod tests {
|
||||||
project_dir.close()
|
project_dir.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_package_version_semantic_development_version() -> io::Result<()> {
|
||||||
|
let config_name = "package.json";
|
||||||
|
let config_content = json::json!({
|
||||||
|
"name": "starship",
|
||||||
|
"version": "0.0.0-development"
|
||||||
|
})
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
let project_dir = create_project_dir()?;
|
||||||
|
fill_config(&project_dir, config_name, Some(&config_content))?;
|
||||||
|
expect_output(&project_dir, Some("semantic"), None);
|
||||||
|
project_dir.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_package_version_with_semantic_other_version() -> io::Result<()> {
|
||||||
|
let config_name = "package.json";
|
||||||
|
let config_content = json::json!({
|
||||||
|
"name": "starship",
|
||||||
|
"version": "v0.0.0-semantically-released"
|
||||||
|
})
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
let project_dir = create_project_dir()?;
|
||||||
|
fill_config(&project_dir, config_name, Some(&config_content))?;
|
||||||
|
expect_output(&project_dir, Some("semantic"), None);
|
||||||
|
project_dir.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_package_version_with_non_semantic_tag() -> io::Result<()> {
|
||||||
|
let config_name = "package.json";
|
||||||
|
let config_content = json::json!({
|
||||||
|
"name": "starship",
|
||||||
|
"version": "v0.0.0-alpha"
|
||||||
|
})
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
let project_dir = create_project_dir()?;
|
||||||
|
fill_config(&project_dir, config_name, Some(&config_content))?;
|
||||||
|
expect_output(&project_dir, Some("v0.0.0-alpha"), None);
|
||||||
|
project_dir.close()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_extract_poetry_version() -> io::Result<()> {
|
fn test_extract_poetry_version() -> io::Result<()> {
|
||||||
let config_name = "pyproject.toml";
|
let config_name = "pyproject.toml";
|
||||||
|
|
Loading…
Reference in New Issue