1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-05 15:57:05 +00:00

[PR #12064/9cba458e backport][stable-12] cargo: fix version parsing when state=latest (#12069)

cargo: fix version parsing when `state=latest` (#12064)

* fix(cargo): fix greedy regex in get_latest_published_version

Fixes #8949

* docs(cargo): add changelog fragment for #12064

(cherry picked from commit 9cba458e3e)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2026-05-17 11:09:33 +02:00 committed by GitHub
parent 7304fd6b3c
commit fb3e873d98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -0,0 +1,4 @@
bugfixes:
- "cargo - fix ``state=latest`` always reporting ``changed`` due to greedy regex capturing description text instead of version string
(https://github.com/ansible-collections/community.general/issues/8949,
https://github.com/ansible-collections/community.general/pull/12064)."

View file

@ -196,7 +196,7 @@ class Cargo:
cmd = ["search", name, "--limit", "1"]
data, dummy = self._exec(cmd, True, False, False)
match = re.search(r'"(.+)"', data)
match = re.search(r"^" + re.escape(name) + r'\s*=\s*"([^"]+)"', data, re.MULTILINE)
if not match:
self.module.fail_json(msg=f"No published version for package {name} found")
return match.group(1)