Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: GitForWindows not returning correct (full) version number #511

Closed
2 tasks done
AScott-WWF opened this issue Jul 14, 2023 · 4 comments
Closed
2 tasks done

[Bug]: GitForWindows not returning correct (full) version number #511

AScott-WWF opened this issue Jul 14, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@AScott-WWF
Copy link

What happened?

Git for Windows appears to be using a 4 part version numbering system for their new releases, but Get-EvergreenApp only returns the first 3 parts (2.41.0)
Unfortunately relying on the version number does not return anything later than the initial 2.41.0.0 release, as of 13th July 2023 the latest version is 2.41.0.3

Can the GitForWindows functionality be updated to handle this extra 4th part of the version?

Version

2305.801

What PowerShell edition/s are you running Evergreen on?

PowerShell Core, Windows PowerShell

Which operating system/s are you running Evergreen on?

Windows 10

Have you reviewed the documentation?

Verbose output

gea Gitforwindows -Verbose | Where-Object Type -eq "exe"
VERBOSE: Function path: C:\Users\username\Documents\WindowsPowerShell\Modules\Evergreen\2303.789\Apps\Get-Gitforwindows.ps1
VERBOSE: Function exists: C:\Users\username\Documents\WindowsPowerShell\Modules\Evergreen\2303.789\Apps\Get-Gitforwindows.ps1.
VERBOSE: Dot sourcing: C:\Users\username\Documents\WindowsPowerShell\Modules\Evergreen\2303.789\Apps\Get-Gitforwindows.ps1.
VERBOSE: Get-FunctionResource: read application resource strings from [C:\Users\username\Documents\WindowsPowerShell\Modules\Evergreen\2303.789\Manifests\Gitforwindows.json]
VERBOSE: Calling: Get-Gitforwindows.
VERBOSE: Get-GitHubRepoRelease: Checking for how many requests to the GitHub API we have left.
VERBOSE: Invoke-RestMethodWrapper: Invoke-RestMethod parameter: UseBasicParsing: True.
VERBOSE: Invoke-RestMethodWrapper: Invoke-RestMethod parameter: MaximumRedirection: 2.
VERBOSE: Invoke-RestMethodWrapper: Invoke-RestMethod parameter: DisableKeepAlive: True.
VERBOSE: Invoke-RestMethodWrapper: Invoke-RestMethod parameter: UserAgent: Mozilla/5.0 (Windows NT; Windows NT 10.0; en-GB) AppleWebKit/534.6 (KHTML, like Gecko) Chrome/7.0.500.0 Safari/534.6.
VERBOSE: Invoke-RestMethodWrapper: Invoke-RestMethod parameter: Method: Default.
VERBOSE: Invoke-RestMethodWrapper: Invoke-RestMethod parameter: Uri: https://api.github.com/rate_limit.
VERBOSE: Invoke-RestMethodWrapper: Invoke-RestMethod parameter: ContentType: application/json; charset=utf-8.
VERBOSE: GET https://api.github.com/rate_limit with 0-byte payload
VERBOSE: received 465-byte response of content type application/json; charset=utf-8
VERBOSE: Get-GitHubRepoRelease: We have 52 requests left to the GitHub API in this window.
VERBOSE: Get-GitHubRepoRelease: Set TLS to Tls12.
VERBOSE: Get-GitHubRepoRelease: Get GitHub release from: https://api.github.com/repos/git-for-windows/git/releases/latest.
VERBOSE: GET https://api.github.com/repos/git-for-windows/git/releases/latest with 0-byte payload
VERBOSE: received -1-byte response of content type application/json; charset=utf-8
VERBOSE: Get-GitHubRepoRelease: Validating GitHub release object.
VERBOSE: Get-GitHubRepoRelease: Validated successfully.
VERBOSE: Get-GitHubRepoRelease: Found  release/s.
VERBOSE: Get-GitHubRepoRelease: Found 12 asset/s.
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-32-bit.exe.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-32-bit.exe.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-32-bit.tar.bz2.
VERBOSE: Get-GitHubRepoRelease: Skip: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-32-bit.tar.bz2.
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-64-bit.exe.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-64-bit.exe.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-64-bit.tar.bz2.
VERBOSE: Get-GitHubRepoRelease: Skip: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-64-bit.tar.bz2.
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/MinGit-2.41.0.3-32-bit.zip.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/MinGit-2.41.0.3-32-bit.zip.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/MinGit-2.41.0.3-64-bit.zip.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/MinGit-2.41.0.3-64-bit.zip.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/MinGit-2.41.0.3-busybox-32-bit.zip.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/MinGit-2.41.0.3-busybox-32-bit.zip.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/MinGit-2.41.0.3-busybox-64-bit.zip.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/MinGit-2.41.0.3-busybox-64-bit.zip.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/pdbs-for-git-32-bit-2.41.0.3.4a1821dfb0-1.zip.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/pdbs-for-git-32-bit-2.41.0.3.4a1821dfb0-1.zip.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/pdbs-for-git-64-bit-2.41.0.3.4a1821dfb0-1.zip.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/pdbs-for-git-64-bit-2.41.0.3.4a1821dfb0-1.zip.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/PortableGit-2.41.0.3-32-bit.7z.exe.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/PortableGit-2.41.0.3-32-bit.7z.exe.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Get-GitHubRepoRelease: Match \.exe$|\.msi$|\.msp$|\.zip$ to https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/PortableGit-2.41.0.3-64-bit.7z.exe.
VERBOSE: Get-GitHubRepoRelease: Building Windows release output object with: https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/PortableGit-2.41.0.3-64-bit.7z.exe.
VERBOSE: ConvertTo-DateTime: Converting: [2023-07-13T21:45:20Z].
VERBOSE: ConvertTo-DateTime: Attempting to convert date format to: en-GB.
VERBOSE: ConvertTo-DateTime: Failed to convert to short date.
VERBOSE: ConvertTo-DateTime: Returning date: [2023-07-13T21:45:20Z].
VERBOSE: Performing the operation "Return output" on target "C:\Users\username\Documents\WindowsPowerShell\Modules\Evergreen\2303.789\Apps\Get-Gitforwindows.ps1".
VERBOSE: Output result from: C:\Users\username\Documents\WindowsPowerShell\Modules\Evergreen\2303.789\Apps\Get-Gitforwindows.ps1.


Version      : 2.41.0
Platform     : Windows
Architecture : x64
Type         : exe
Date         : 2023-07-13T21:45:20Z
Size         : 57718936
URI          : https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/PortableGit-2.41.0.3-64-bit.7z.exe

Version      : 2.41.0
Platform     : Windows
Architecture : x86
Type         : exe
Date         : 2023-07-13T21:45:20Z
Size         : 57899960
URI          : https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/PortableGit-2.41.0.3-32-bit.7z.exe

Version      : 2.41.0
Platform     : Windows
Architecture : x64
Type         : exe
Date         : 2023-07-13T21:45:20Z
Size         : 61230448
URI          : https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-64-bit.exe

Version      : 2.41.0
Platform     : Windows
Architecture : x86
Type         : exe
Date         : 2023-07-13T21:45:20Z
Size         : 61817976
URI          : https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-32-bit.exe
@AScott-WWF AScott-WWF added the bug Something isn't working label Jul 14, 2023
@AScott-WWF
Copy link
Author

I have updated Evergreen twice since this update - I'm now running the latest Evergreen v2307.816
It is unclear why this issue was closed as completed, as the Get-EvergreenApp GitForWindows is still returning a 3 digit version number, currently it is still returning 2.41.0 when the latest version is 2.41.0.3:
For example:

Version       : 2.41.0
Platform      : Windows
Architecture  : x86
Type          : exe
InstallerType : Default
Date          : 13/07/2023
Size          : 61817976
URI           : https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-32-bit.exe

I'm wondering if the version needs to be worked out using a better RegEx to capture the version number from the URI
e.g. 'v2.41.0.windows.3' becomes 2.41.0.3 (by stripping off leading v and windows.)
or 'Git-2.41.0.3-32-bit.exe' becomes 2.41.0.3 (by stripping off leading Git- and trailing -32-bit.exe
Using the above example this should return the full (4 part) version number:

Version       : 2.41.0.3
Platform      : Windows
Architecture  : x86
Type          : exe
InstallerType : Default
Date          : 13/07/2023
Size          : 61817976
URI           : https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-32-bit.exe

@aaronparker aaronparker reopened this Jul 31, 2023
@AScott-WWF
Copy link
Author

AScott-WWF commented Aug 4, 2023

Not sure if this helps, but I have been using the following in my script to return the latest 'full' version number:

$AppName = GitForWindows
$Arch = "x64"
$AppType = "EXE"

$ThisApp = (Get-EvergreenApp $($AppName) | Where-Object {$_.Architecture -eq $($Arch) -and $_.Type -eq $($AppType).ToLower() -and $_.URI -notlike "*PortableGit*"})
#[version]$LatestVersion = $ThisApp.Version
$SourceUrl = $ThisApp.URI
# Evergreen version returns 3 digit version so obtain 4 digit version from URI
[version]$LatestVersion = (((($ThisApp).URI -split "/")[7]) -replace '^v') -replace '.windows'

aaronparker added a commit that referenced this issue Sep 20, 2023
Add support for replacing text in tag/version string returned from the target repo #511
aaronparker added a commit that referenced this issue Sep 20, 2023
Add replace ".windows" in version tag to return a proper version number. Return .exe installers only to simplify returning installer downloads (remove .zip installers that return mingit and busybox versions)
@AScott-WWF
Copy link
Author

Thanks @aaronparker really appreciate the effort
This works perfect now

@AScott-WWF
Copy link
Author

@aaronparker, Sorry to return back this earlier issue...

I raised a bug with the Git for Windows developers today due to their 'choice' of populating the FileVersion attribute on their executables and dlls with a 5 part version number 🤯
But I had a rather helpful response back which clarifies an earlier uncertainty on this Evergreen issue, see here: git-for-windows/git#5319 (comment)
I therefore believe that the modification made earlier to fix this Evergreen issue is now slightly incorrect...
As the current version number supplied by the Git data source is 5 parts and ends with a 1 (e.g. 2.47.1.windows.1), the version is apparently 2.47.1 (the last 1 is always ignored as it is referred to as the 1st version), however, if there was a subsequent dot release for the current version it would then be 2.47.1.2

I therefore believe the code you have to determine the Git for Windows version probably needs to be tweaked, so it can correctly handle this logic.
It should still strip the .windows (as it does currently) and then if the last part is .1 it strips this too
So for a new Minor release it is a 3 part version number (Major.Minor.Build)
However, if the last part is greater than 1, it is a revision / dot release so therefore becomes a 4 part version number (Major.Minor.Build.Revision)

I expect making this change might have some unintended consequences for some folk using automation as the current version would change (reduce) from 2.47.1.1 to 2.47.1, but I believe this should only be an issue for 1 release - unless the code change was made during a 4 part version numbered release 🤷‍♂️
No urgency at all, just thought it would be helpful to share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants