@@ -118,6 +118,7 @@ Name: windowsterminal; Description: "(NEW!) Add a Git Bash Profile to Windows Te
118
118
#ifdef WITH_SCALAR
119
119
Name : scalar; Description : " (NEW!) Scalar (Git add-on to manage large-scale repositories)" ; Types : default
120
120
#endif
121
+ Name : poshgit; Description : " (NEW!) Install Posh-Git from the PSGallery"
121
122
122
123
123
124
[Run]
@@ -1096,8 +1097,8 @@ begin
1096
1097
end ;
1097
1098
#endif
1098
1099
RegQueryStringValue(HKEY_LOCAL_MACHINE,' Software\GitForWindows' ,' CurrentVersion' ,PreviousGitForWindowsVersion);
1099
- // The Windows Terminal profile is new in v2.32 .0
1100
- HasUnseenComponents:=IsUpgrade(' 2.32 .0' );
1100
+ // The Posh-Git option is new in v2.35 .0
1101
+ HasUnseenComponents:=IsUpgrade(' 2.35 .0' );
1101
1102
if HasUnseenComponents then
1102
1103
AddToSet(CustomPagesWithUnseenOptions,wpSelectComponents);
1103
1104
#if APP_VERSION!=' 0-test'
@@ -2940,6 +2941,7 @@ end;
2940
2941
procedure CurStepChanged (CurStep:TSetupStep);
2941
2942
var
2942
2943
DllPath,FileName,Cmd,Msg,Ico:String;
2944
+ ExitCode:DWORD;
2943
2945
BuiltIns,ImageNames,EnvPath:TArrayOfString;
2944
2946
Count,i:Longint;
2945
2947
RootKey:Integer;
@@ -3366,6 +3368,40 @@ begin
3366
3368
InstallWindowsTerminalFragment();
3367
3369
end ;
3368
3370
3371
+ {
3372
+ Install Posh-Git from the PSGallery
3373
+ }
3374
+
3375
+ if (IsComponentSelected(' poshgit' )) then begin
3376
+ WizardForm.StatusLabel.Caption:=' Installing Posh-Git from the PSGallery' ;
3377
+ // Must use the sysnative version of PowerShell, otherwise will target the wrong profile
3378
+ Cmd:=' "' +ExpandConstant(' {sysnative}\WindowsPowerShell\v1.0\powershell.exe' )+' "' +
3379
+ ' -ExecutionPolicy Bypass -NoProfile -NoLogo -NonInteractive -WindowStyle Hidden -command "' +
3380
+ ' if (!(Get-PackageProvider -Name NuGet)) {' +
3381
+ ' Install-PackageProvider -Name NuGet -Force ' +
3382
+ ' } ' +
3383
+ ' $policy = (Get-PSRepository -Name PSGallery).InstallationPolicy; ' +
3384
+ ' if ($policy -ne """Trusted""") {' +
3385
+ ' Set-PSRepository -Name PSGallery -InstallationPolicy Trusted ' +
3386
+ ' } ' +
3387
+ ' Uninstall-Package posh-git -Scope AllUsers -ErrorAction SilentlyContinue; ' +
3388
+ ' Install-Module -Repository PSGallery -Scope AllUsers posh-git; ' +
3389
+ ' $res=$?; ' +
3390
+ ' if ($policy -ne """Trusted""") {' +
3391
+ ' Set-PSRepository -Name PSGallery -InstallationPolicy $policy ' +
3392
+ ' } ' +
3393
+ ' if ($res) {' +
3394
+ ' Add-PoshGitToProfile -AllUsers; ' +
3395
+ ' $res=$? ' +
3396
+ ' } ' +
3397
+ ' if (!$res) {' +
3398
+ ' exit(1) ' +
3399
+ ' }"' ;
3400
+ if not ExecWithCapture(Cmd,Msg,Msg,ExitCode) or (ExitCode<>0 ) then
3401
+ LogError(' Failed to install Posh-Git:' +#13 +Msg);
3402
+ end ;
3403
+
3404
+
3369
3405
{
3370
3406
Optionally "skip" installing bundled SSH binaries conflicting with external OpenSSH:
3371
3407
}
@@ -3812,4 +3848,24 @@ begin
3812
3848
if not DeleteFile(FileName) then
3813
3849
LogError(' Line {#__LINE__}: Unable to delete file "' +FileName+' ". Please do it manually after logging off and on again.' );
3814
3850
end ;
3851
+
3852
+ {
3853
+ Remove posh-git
3854
+ }
3855
+
3856
+ if (IsComponentSelected(' poshgit' )) then begin
3857
+ Cmd:=' "' +ExpandConstant(' {sysnative}\WindowsPowerShell\v1.0\powershell.exe' )+' "' +
3858
+ ' -ExecutionPolicy Bypass -NoProfile -NoLogo -NonInteractive -WindowStyle Hidden -command "' +
3859
+ ' Uninstall-Package posh-git -Scope AllUsers -ErrorAction SilentlyContinue; ' +
3860
+ ' $res=$?; ' +
3861
+ ' if ($res) {' +
3862
+ ' Remove-PoshGitFromProfile -AllUsers; ' +
3863
+ ' $res=$? ' +
3864
+ ' } ' +
3865
+ ' if (!$res) {' +
3866
+ ' exit(1) ' +
3867
+ ' }"' ;
3868
+ if not ExecWithCapture(Cmd,Msg,Msg,ExitCode) or (ExitCode<>0 ) then
3869
+ LogError(' Failed to install Posh-Git:' +#13 +Msg);
3870
+ end ;
3815
3871
end ;
0 commit comments