From 4d4f45442416b0f5f266f743dd62e1ee79d14f71 Mon Sep 17 00:00:00 2001 From: Maksim Shilov <89912354+shilovmaksim@users.noreply.github.com> Date: Fri, 18 Feb 2022 10:23:34 +0300 Subject: [PATCH] [All OS] Output full version of git to software report (#5097) --- .../scripts/SoftwareReport/SoftwareReport.Tools.psm1 | 3 +-- .../macos/software-report/SoftwareReport.Common.psm1 | 4 ++-- .../SoftwareReport/SoftwareReport.Helpers.psm1 | 12 ++++++++++++ .../scripts/SoftwareReport/SoftwareReport.Tools.psm1 | 3 +-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index fa6cea41..bcfe1b84 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -89,8 +89,7 @@ function Get-DockerBuildxVersion { } function Get-GitVersion { - $result = Get-CommandResult "git --version" - $gitVersion = $result.Output | Take-OutputPart -Part 2 + $gitVersion = git --version | Take-OutputPart -Part -1 $aptSourceRepo = Get-AptSourceRepository -PackageName "git-core" return "Git $gitVersion (apt source repository: $aptSourceRepo)" } diff --git a/images/macos/software-report/SoftwareReport.Common.psm1 b/images/macos/software-report/SoftwareReport.Common.psm1 index b3282b10..df7ff83e 100644 --- a/images/macos/software-report/SoftwareReport.Common.psm1 +++ b/images/macos/software-report/SoftwareReport.Common.psm1 @@ -266,8 +266,8 @@ function Get-CurlVersion { } function Get-GitVersion { - $gitVersion = Run-Command "git --version" | Take-Part -Part 2 - return "Git: $gitVersion" + $gitVersion = Run-Command "git --version" | Take-Part -Part -1 + return "Git $gitVersion" } function Get-GitLFSVersion { diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 index b62fda7e..1318d727 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 @@ -161,3 +161,15 @@ function Test-BlankElement { exit 1 } } + +function Take-Part { + param ( + [Parameter(ValueFromPipeline)] + [string] $toolOutput, + [string] $Delimiter = " ", + [int[]] $Part + ) + $parts = $toolOutput.Split($Delimiter, [System.StringSplitOptions]::RemoveEmptyEntries) + $selectedParts = $parts[$Part] + return [string]::Join($Delimiter, $selectedParts) +} \ No newline at end of file diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index c092494b..d714f83c 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -67,8 +67,7 @@ function Get-DockerWincredVersion { } function Get-GitVersion { - $(git version) -match "git version (?\d+\.\d+\.\d+)" | Out-Null - $gitVersion = $Matches.Version + $gitVersion = git --version | Take-Part -Part -1 return "Git $gitVersion" }