Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/pyinfra/facts/brew.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

from .util.packaging import parse_packages

BREW_REGEX = r"^([^\s]+)\s([0-9\._+a-z\-]+)"
PKG_VERSION_SEP = "@"
BREW_REGEX = rf"^([^{PKG_VERSION_SEP}]+)(?:{PKG_VERSION_SEP}[0-9\.]+)?\s([0-9\._+a-z\-]+)"


def new_cask_cli(version):
Expand Down
11 changes: 9 additions & 2 deletions src/pyinfra/operations/brew.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@

from pyinfra import host
from pyinfra.api import operation
from pyinfra.facts.brew import BrewCasks, BrewPackages, BrewTaps, BrewVersion, new_cask_cli
from pyinfra.facts.brew import (
PKG_VERSION_SEP,
BrewCasks,
BrewPackages,
BrewTaps,
BrewVersion,
new_cask_cli,
)

from .util.packaging import ensure_packages

Expand Down Expand Up @@ -153,7 +160,7 @@ def casks(
install_command="brew %sinstall%s" % args,
uninstall_command="brew %suninstall%s" % args,
upgrade_command="brew %supgrade%s" % args,
version_join="@",
version_join=PKG_VERSION_SEP,
latest=latest,
)

Expand Down
7 changes: 7 additions & 0 deletions tests/facts/brew.BrewPackages/no_packages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"command": "brew list --versions",
"requires_command": "brew",
"output": [],
"fact": {
}
}
13 changes: 13 additions & 0 deletions tests/facts/brew.BrewPackages/package_with_multiple_versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"command": "brew list --versions",
"requires_command": "brew",
"output": [
"python@3.13 3.13.2",
"python@3.14 3.14.3"
],
"fact": {
"python": [
"3.13.2", "3.14.3"
]
}
}
2 changes: 1 addition & 1 deletion tests/facts/brew.BrewPackages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"zlib": [
"1.2.11"
],
"python@3.13": [
"python": [
"3.13.2"
]
}
Expand Down
Loading