Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions GVFS/GVFS.Installer.Windows/Setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,70 @@ begin
Result := True;
end;

type
UpgradeRing = (urUnconfigured, urNone, urFast, urSlow);

function GetConfiguredUpgradeRing(): UpgradeRing;
var
ResultCode: integer;
ResultString: ansiString;
begin
Result := urUnconfigured;
if ExecWithResult('gvfs.exe', 'config upgrade.ring', '', SW_HIDE, ewWaitUntilTerminated, ResultCode, ResultString) then begin
if ResultCode = 0 then begin
ResultString := AnsiLowercase(Trim(ResultString));
Log('GetConfiguredUpgradeRing: upgrade.ring is ' + ResultString);
if CompareText(ResultString, 'none') = 0 then begin
Result := urNone;
end else if CompareText(ResultString, 'fast') = 0 then begin
Result := urFast;
end else if CompareText(ResultString, 'slow') = 0 then begin
Result := urSlow;
end else begin
Log('GetConfiguredUpgradeRing: Unknown upgrade ring: ' + ResultString);
end;
end else begin
Log('GetConfiguredUpgradeRing: Call to gvfs config upgrade.ring failed with ' + SysErrorMessage(ResultCode));
end;
end else begin
Log('GetConfiguredUpgradeRing: Call to gvfs config upgrade.ring failed with ' + SysErrorMessage(ResultCode));
end;
end;

procedure SetNuGetFeedIfNecessary();
var
ConfiguredRing: UpgradeRing;
RingName: String;
TargetFeed: String;
FeedPackageName: String;
ResultCode: Integer;
ResultString: ansiString;
begin
ConfiguredRing := GetConfiguredUpgradeRing();
if ConfiguredRing = urFast then begin
RingName := 'Fast';
end else if (ConfiguredRing = urSlow) or (ConfiguredRing = urNone) then begin
RingName := 'Slow';
end else begin
Log('SetNuGetFeedIfNecessary: No upgrade ring configured. Not configuring NuGet feed.')
exit;
end;

TargetFeed := Format('https://pkgs.dev.azure.com/microsoft/_packaging/VFSForGit-%s/nuget/v3/index.json', [RingName]);
FeedPackageName := 'Microsoft.VfsForGitEnvironment';
if ExecWithResult('gvfs.exe', Format('config upgrade.feedurl %s', [TargetFeed]), '', SW_HIDE, ewWaitUntilTerminated, ResultCode, ResultString) then begin
Log('SetNuGetFeedIfNecessary: Set upgrade.feedurl to ' + TargetFeed);
end else begin
Log('SetNuGetFeedIfNecessary: Failed to set upgrade.feedurl with ' + SysErrorMessage(ResultCode));
end;

if ExecWithResult('gvfs.exe', Format('config upgrade.feedpackagename %s', [FeedPackageName]), '', SW_HIDE, ewWaitUntilTerminated, ResultCode, ResultString) then begin
Log('SetNuGetFeedIfNecessary: Set upgrade.feedpackagename to ' + FeedPackageName)
end else begin
Log('SetNuGetFeedIfNecessary: Failed to set upgrade.feedpackagename with ' + SysErrorMessage(ResultCode));
end;
end;

// Below are EVENT FUNCTIONS -> The main entry points of InnoSetup into the code region
// Documentation : http://www.jrsoftware.org/ishelp/index.php?topic=scriptevents

Expand Down Expand Up @@ -673,6 +737,7 @@ function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
NeedsRestart := False;
Result := '';
SetNuGetFeedIfNecessary();
if ConfirmUnmountAll() then
begin
if ExpandConstant('{param:REMOUNTREPOS|true}') = 'true' then
Expand Down