Skip to content

Commit

Permalink
Merge pull request #2161 from brogers5/tortoisegit-skip-install-of-cu…
Browse files Browse the repository at this point in the history
…rrent-version
  • Loading branch information
AdmiringWorm authored Mar 23, 2023
2 parents 70e3447 + 03014a1 commit 47bb1bb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
36 changes: 17 additions & 19 deletions automatic/tortoisegit/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
$ErrorActionPreference = 'Stop'

$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
. $toolsPath\helpers.ps1

$filePath32 = Resolve-Path "$toolsPath\*_x32.msi"
$filePath64 = Resolve-Path "$toolsPath\*_x64.msi"
[version] $softwareVersion = '2.14.0.0'
$installedVersion = Get-InstalledVersion

$installFile = if ((Get-OSArchitectureWidth 64) -and $env:chocolateyForceX86 -ne 'true') {
Write-Host "Installing 64 bit version"
$filePath64
} else {
Write-Host "Installing 32 bit version"
$filePath32
if ($installedVersion -and ($softwareVersion -eq $installedVersion) -and !$env:ChocolateyForce) {
Write-Host "TortoiseGit v$installedVersion is already installed - skipping download and installation."
}
else {
$packageArgs = @{
PackageName = 'tortoisegit'
FileType = 'msi'
SoftwareName = 'TortoiseGit*'
File = "$toolsPath\"
File64 = "$toolsPath\"
SilentArgs = '/quiet /qn /norestart REBOOT=ReallySuppress'
ValidExitCodes = @(0, 3010)
}

$packageArgs = @{
PackageName = 'tortoisegit'
FileType = 'msi'
SoftwareName = 'TortoiseGit*'
File = $installFile
SilentArgs = '/quiet /qn /norestart REBOOT=ReallySuppress'
ValidExitCodes = @(0,3010)
Install-ChocolateyInstallPackage @packageArgs
}

Install-ChocolateyInstallPackage @packageArgs

# Lets remove the installer as there is no more need for it.
Remove-Item -Force $filePath32 -ea 0
Remove-Item -Force $filePath64 -ea 0
Remove-Item -Force "$toolsPath\*.msi" -ea 0
9 changes: 9 additions & 0 deletions automatic/tortoisegit/tools/helpers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Get-InstalledVersion() {
[array] $keys = Get-UninstallRegistryKey -SoftwareName 'TortoiseGit*'

if ($keys.Length -ge 1) {
return [version] ($keys[0].DisplayVersion)
}

return $null
}
35 changes: 21 additions & 14 deletions automatic/tortoisegit/update.ps1
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
import-module au
import-module au
import-module "$PSScriptRoot/../../extensions/extensions.psm1"

$releases = 'https://tortoisegit.org/download/'

function global:au_BeforeUpdate {
$Latest.ChecksumType = "sha256"
Get-RemoteFiles -Purge
Get-RemoteFiles -Purge -NoSuffix
}

function global:au_SearchReplace {
@{
".\tortoisegit.nuspec" = @{
"tools\chocolateyInstall.ps1" = @{
"(?i)([$]softwareVersion\s*=\s*)'.*'" = "`${1}'$($Latest.RemoteVersion)'"
"(?i)(^\s*fileType\s*=\s*)('.*')" = "`$1'$($Latest.FileType)'"
"(?i)(^\s*file\s*=\s*`"[$]toolsPath\\).*" = "`${1}$($Latest.FileName32)`""
"(?i)(^\s*file64\s*=\s*`"[$]toolsPath\\).*" = "`${1}$($Latest.FileName64)`""
}
".\tortoisegit.nuspec" = @{
"(<releaseNotes>https:\/\/tortoisegit.org\/docs\/releasenotes\/#Release_)(.*)(<\/releaseNotes>)" = "`${1}$($Latest.Version.ToString())`$3"
}
".\legal\verification.txt" = @{
"(?i)(32-Bit.+)\<.*\>" = "`${1}<$($Latest.URL32)>"
"(?i)(64-Bit.+)\<.*\>" = "`${1}<$($Latest.URL64)>"
".\legal\verification.txt" = @{
"(?i)(32-Bit.+)\<.*\>" = "`${1}<$($Latest.URL32)>"
"(?i)(64-Bit.+)\<.*\>" = "`${1}<$($Latest.URL64)>"
"(?i)(checksum type:\s+).*" = "`${1}$($Latest.ChecksumType)"
"(?i)(checksum32:\s+).*" = "`${1}$($Latest.Checksum32)"
"(?i)(checksum64:\s+).*" = "`${1}$($Latest.Checksum64)"
"(?i)(checksum32:\s+).*" = "`${1}$($Latest.Checksum32)"
"(?i)(checksum64:\s+).*" = "`${1}$($Latest.Checksum64)"
}
}
}
}

function global:au_GetLatest {
$download_page = Invoke-WebRequest -UseBasicParsing -Uri $releases

#https://download.tortoisegit.org/tgit/2.3.0.0/TortoiseGit-2.3.0.0-32bit.msi
$re32 = "TortoiseGit-(.*)-32bit.msi"
$re32 = "TortoiseGit-(.*)-32bit.msi"
$url32 = $download_page.links | Where-Object href -match $re32 | Select-Object -First 1 -expand href

#https://download.tortoisegit.org/tgit/2.3.0.0/TortoiseGit-2.3.0.0-64bit.msi
$re64 = "TortoiseGit-(.*)-64bit.msi"
$re64 = "TortoiseGit-(.*)-64bit.msi"
$url64 = $download_page.links | Where-Object href -match $re64 | Select-Object -First 1 -expand href

$version32 = $url32 -split '-' | Select-Object -Skip 1 -First 1
Expand All @@ -42,9 +48,10 @@ function global:au_GetLatest {
}

return @{
URL32 = "https:" + $url32
URL64 = "https:" + $url64
Version = $version32
URL32 = "https:" + $url32
URL64 = "https:" + $url64
Version = $version32
RemoteVersion = $version32
}
}

Expand Down

0 comments on commit 47bb1bb

Please sign in to comment.