diff --git a/scripts/Common/Software/git/Manage.ps1 b/scripts/Common/Software/git/Manage.ps1 new file mode 100644 index 00000000..f3c10a45 --- /dev/null +++ b/scripts/Common/Software/git/Manage.ps1 @@ -0,0 +1,18 @@ +param ( + $Action, + [hashtable] $Arguments +) + +. "$PSScriptRoot/../../Scripts/Software.ps1"; +. "$PSScriptRoot/../../Types/InstallerAction.ps1"; + +Start-SoftwareInstaller @PSBoundParameters ` + -Installer { + param( + [scriptblock] $Installer + ) + + & $Installer -Action ([InstallerAction]::Configure); + } ` + -Configurator { + }; diff --git a/scripts/Windows/Software/git/Manage.ps1 b/scripts/Windows/Software/git/Manage.ps1 new file mode 100644 index 00000000..92578fdc --- /dev/null +++ b/scripts/Windows/Software/git/Manage.ps1 @@ -0,0 +1,64 @@ +param ( + $Action, + [hashtable] $Arguments +) + +. "$PSScriptRoot/../../../Common/Scripts/Config.ps1"; +. "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; +. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1"; + +$null = New-Module { + param( + [hashtable] $Parameters + ) + + . "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1"; + + <# + .SYNOPSIS + Gets a configuration value related to git. + + .PARAMETER Name + The name of the configuration to get. + + .PARAMETER User + The name of the user to get the configuration for. + #> + function Get-GitOption { + param( + [Parameter(Mandatory)] + [string] $Name, + [string] $User + ) + + $config = "git.$Name"; + + if ($User) { + Get-UserConfig -UserName $User -Name $config; + } else { + Get-Config $config; + } + } + + Start-SoftwareInstaller @Parameters ` + -Installer { + param( + [scriptblock] $Installer + ) + + $params = "/WindowsTerminalProfile"; + $defaultBranch = Get-GitOption "defaultBranch"; + + if ($defaultBranch) { + $params += " /DefaultBranchName:`"$defaultBranch`""; + } + + Install-ChocoPackage git -ArgumentList "--params",$params; + & $Installer -Action ([InstallerAction]::Configure); + } ` + -Configurator { + & "$PSScriptRoot/../../../Common/Software/git/Manage.ps1" @Parameters; + }; + + Export-ModuleMember -Function @(); +} -ArgumentList $PSBoundParameters