summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/modules/package.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/modules/package.rs b/src/modules/package.rs
index 909998d7b..bd7372ca6 100644
--- a/src/modules/package.rs
+++ b/src/modules/package.rs
@@ -68,6 +68,11 @@ fn extract_package_version(file_contents: &str, display_private: bool) -> Option
};
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)
}
@@ -344,6 +349,51 @@ mod tests {
}
#[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]
fn test_extract_poetry_version() -> io::Result<()> {
let config_name = "pyproject.toml";
let config_content = toml::toml! {