From 3a61bd63f1fa1d05f285f9276d5fbaffdea9bc0a Mon Sep 17 00:00:00 2001 From: Tom <73077675+tmzane@users.noreply.github.com> Date: Sat, 30 Mar 2024 18:26:17 +0500 Subject: [PATCH] feat(homebrew_upgrades): list only manually installed formulas --- homebrew_upgrades.1d.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/homebrew_upgrades.1d.py b/homebrew_upgrades.1d.py index 317b85a..121d28d 100755 --- a/homebrew_upgrades.1d.py +++ b/homebrew_upgrades.1d.py @@ -22,15 +22,13 @@ def __init__(self, name: str, current_version: str, **_: object): def main() -> None: - cmd = subprocess.run( - [BREW_PATH, "outdated", "--json"], - check=True, - text=True, - capture_output=True, - ) + dump = subprocess.check_output([BREW_PATH, "bundle", "dump", "--file=-", "--formula"], text=True) + manually_installed = {line.split('"')[1] for line in dump.splitlines()} # format: brew "name", ... + + outdated = subprocess.check_output([BREW_PATH, "outdated", "--json"], text=True) + data = json.loads(outdated) - data = json.loads(cmd.stdout) - formulas = [Package(**obj) for obj in data["formulae"]] + formulas = [Package(**obj) for obj in data["formulae"] if obj["name"] in manually_installed] casks = [Package(**obj) for obj in data["casks"]] total = len(formulas) + len(casks)