From da684ca6d2b6de512a4dec746c7c134d2b010626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20=C3=87ak=C4=B1r?= Date: Tue, 30 Jul 2024 20:11:12 +0300 Subject: [PATCH] [Ubuntu] Make brew version check consistent (#10369) `Tools.Tests.ps1` checks the version of `brew` with `--version` argument. ```powershell Describe "Homebrew" { It "homebrew" { "/home/linuxbrew/.linuxbrew/bin/brew --version" | Should -ReturnZeroExitCode } } ``` `SoftwareReport.Common.psm1` checks it with `-v` argument. ```powershell function Get-HomebrewVersion { $result = Get-CommandResult "/home/linuxbrew/.linuxbrew/bin/brew -v" $result.Output -match "Homebrew (?\d+\.\d+\.\d+)" | Out-Null return $Matches.version } ``` Generally, `--version` and `-v` are equivalent. But a recent bug in `brew` makes `-v` returns the output of `brew help`. https://github.com/Homebrew/brew/pull/17903 It's best to maintain consistency in version checks and explicitly use `--version` in both places. --- images/ubuntu/scripts/docs-gen/SoftwareReport.Common.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/ubuntu/scripts/docs-gen/SoftwareReport.Common.psm1 b/images/ubuntu/scripts/docs-gen/SoftwareReport.Common.psm1 index 62e39cae747d..73e3e1f3ebf6 100644 --- a/images/ubuntu/scripts/docs-gen/SoftwareReport.Common.psm1 +++ b/images/ubuntu/scripts/docs-gen/SoftwareReport.Common.psm1 @@ -131,7 +131,7 @@ function Get-LernaVersion { } function Get-HomebrewVersion { - $result = Get-CommandResult "/home/linuxbrew/.linuxbrew/bin/brew -v" + $result = Get-CommandResult "/home/linuxbrew/.linuxbrew/bin/brew --version" $result.Output -match "Homebrew (?\d+\.\d+\.\d+)" | Out-Null return $Matches.version }