From 07778a8452bb565db55e32c32d7c8434a7bda9dd Mon Sep 17 00:00:00 2001 From: -k Date: Sun, 17 Aug 2025 10:52:52 -0700 Subject: [PATCH] feat(package): Add support for Ansible Galaxy (#6905) --- docs/config/README.md | 3 ++- src/modules/package.rs | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/config/README.md b/docs/config/README.md index fdf3ab88e..5aaba98d1 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -3558,7 +3558,7 @@ Arch = "Arch is the best! " The `package` module is shown when the current directory is the repository for a package, and shows its current version. The module currently supports `npm`, `nimble`, `cargo`, -`poetry`, `python`, `composer`, `gradle`, `julia`, `mix`, `helm`, `shards`, `daml` and `dart` packages. +`poetry`, `python`, `composer`, `gradle`, `julia`, `mix`, `helm`, `shards`, `galaxy`, `daml` and `dart` packages. - [**npm**](https://docs.npmjs.com/cli/commands/npm) – The `npm` package version is extracted from the `package.json` present in the current directory @@ -3577,6 +3577,7 @@ package, and shows its current version. The module currently supports `npm`, `ni - [**Maven**](https://maven.apache.org/) - The `maven` package version is extracted from the `pom.xml` present in the current directory - [**Meson**](https://mesonbuild.com/) - The `meson` package version is extracted from the `meson.build` present in the current directory - [**Shards**](https://crystal-lang.org/reference/the_shards_command/index.html) - The `shards` package version is extracted from the `shard.yml` present in the current directory +- [**Galaxy**](https://galaxy.ansible.com/) - The `galaxy` package version is extracted from the `galaxy.yml` present in the current directory - [**V**](https://vlang.io) - The `vlang` package version is extracted from the `v.mod` present in the current directory - [**SBT**](https://scala-sbt.org) - The `sbt` package version is extracted from the `build.sbt` present in the current directory - [**Daml**](https://www.digitalasset.com/developers) - The `daml` package version is extracted from the `daml.yaml` present in the current directory diff --git a/src/modules/package.rs b/src/modules/package.rs index a5e306a15..01957f8e8 100644 --- a/src/modules/package.rs +++ b/src/modules/package.rs @@ -343,6 +343,14 @@ fn get_rlang_version(context: &Context, config: &PackageConfig) -> Option Option { + let file_contents = context.read_file_from_pwd("galaxy.yml")?; + let data = yaml_rust2::YamlLoader::load_from_str(&file_contents).ok()?; + let raw_version = data.first()?["version"].as_str()?; + + format_version(raw_version, config.version_format) +} + fn get_version(context: &Context, config: &PackageConfig) -> Option { let package_version_fn: Vec Option> = vec![ get_cargo_version, @@ -365,6 +373,7 @@ fn get_version(context: &Context, config: &PackageConfig) -> Option { get_daml_project_version, get_dart_pub_version, get_rlang_version, + get_galaxy_version, ]; package_version_fn.iter().find_map(|f| f(context, config)) @@ -1547,6 +1556,20 @@ Title: Starship expect_output(&project_dir, Some("v1.0.0"), None); project_dir.close() } + + #[test] + fn test_ansible_galaxy_version() -> io::Result<()> { + let config_name = "galaxy.yml"; + let config_content = "namespace: starfleet\nname: starship\nversion: 1.2.3\n".to_string(); + + 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() + } + fn create_project_dir() -> io::Result { tempfile::tempdir() }