Skip to content

Commit e6d1b13

Browse files
committed
Add Git
1 parent 90059ed commit e6d1b13

5 files changed

Lines changed: 89 additions & 0 deletions

File tree

Apps/Git/detect.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#region Setup
2+
$AppName = "Git"
3+
$AppNameFilter = { $_.DisplayName -eq "$AppName" }
4+
$CommonLocation = "Git\cmd\git.exe"
5+
6+
$Locations = @(
7+
# User Locations
8+
[string](Join-path $env:LOCALAPPDATA "Programs\$CommonLocation")
9+
10+
# System Locations
11+
[string](Join-path $env:ProgramFiles $CommonLocation)
12+
[string](Join-path ${env:ProgramFiles(x86)} $CommonLocation)
13+
)
14+
#endregion
15+
16+
############
17+
18+
#region Define Functions
19+
function Test-FilePresence {
20+
param ($f)
21+
if(Test-Path $f){
22+
Write-Output "Located at '$f'"
23+
exit 0
24+
}
25+
}
26+
function Find-UninstallKey {
27+
param ()
28+
$x = @(
29+
# User Locations
30+
"Registry::HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
31+
"Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall"
32+
33+
# System Locations
34+
"Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
35+
"Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
36+
) | ForEach-Object {
37+
if(Test-Path $_){
38+
Get-ChildItem $_ | ForEach-Object {
39+
Get-ItemProperty $_.PSPath
40+
} | Where-Object -FilterScript $AppNameFilter # git specific
41+
}
42+
}
43+
if($null -ne $x){
44+
Write-Output "Found Uninstall Keys"
45+
exit 0
46+
}
47+
}
48+
#endregion
49+
#region Check Presence
50+
# confirm files don't exist on common paths
51+
$Locations | ForEach-Object {
52+
Test-FilePresence -f $_
53+
}
54+
55+
# confirm no matching products installed, in case installed in a different directory
56+
Find-UninstallKey
57+
58+
exit 1
59+
#endregion

Apps/Git/download.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<#
2+
.DESCRIPTION
3+
Script downloads installer for the software.
4+
Since (in most cases) we aren't allowed to redistribute the installers, a script to download them on demand is provided instead.
5+
6+
To use, fill out the parameters in the script, so all you need to do is run ./download.ps1
7+
8+
For GitHub Releases that change, a script is provided in /scripts/Get-LatestGitHubRelease.ps1 to get the latest link which you can pass in via -URI.
9+
10+
(this download script could probably be improved later down the line across the board)
11+
12+
.EXAMPLE
13+
# Get the latest ARM version of PowerShell
14+
$URI = (& '../../Scripts/Get-LatestGitHubRelease.ps1' -Repo 'PowerShell/PowerShell' -Filter {$_.name -like '*win-arm64.msi'}).DownloadURI,
15+
./download.ps1 -URI $URI -OutFileName 'ps7-win-arm64.msi'
16+
#>
17+
[CmdletBinding()]
18+
param(
19+
[Parameter()]
20+
[uri]$URI = (& (Join-Path $PSScriptRoot '../../scripts/Get-LatestGitHubRelease.ps1') -Repo 'git-for-windows/git' -Filter {$_.name -like '*64-bit.exe'}).DownloadURI,
21+
[Parameter()]
22+
[string]$OutFileName = 'Git-Installer.exe'
23+
)
24+
25+
$OutPath = Join-Path -Path (Join-Path $PSScriptRoot 'source') -ChildPath $OutFileName
26+
Invoke-RestMethod -Method Get -Uri $URI -OutFile $OutPath -UseBasicParsing -ErrorAction Stop
27+
28+
return $OutFileName

Apps/Git/logo.png

2.33 KB
Loading

Apps/Git/source/install.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Git-Installer.exe /VERYSILENT /NORESTART /LOG="%WINDIR%\Temp\Git-Install.log"

Apps/Git/source/uninstall.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cmd.exe /c ""%LOCALAPPDATA%\Programs\Git\unins000.exe" /VERYSILENT /NORESTART"

0 commit comments

Comments
 (0)