Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Upgrade Messages for Mac #1452

Merged
merged 1 commit into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions GVFS/GVFS.Common/GVFSConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,13 @@ public static class Unmount
public static class UpgradeVerbMessages
{
public const string GVFSUpgrade = "`gvfs upgrade`";
public const string GVFSUpgradeConfirm = "`gvfs upgrade --confirm`";
public const string GVFSUpgradeDryRun = "`gvfs upgrade --dry-run`";
public const string NoUpgradeCheckPerformed = "No upgrade check was performed.";
public const string NoneRingConsoleAlert = "Upgrade ring set to \"None\". " + NoUpgradeCheckPerformed;
public const string NoRingConfigConsoleAlert = "Upgrade ring is not set. " + NoUpgradeCheckPerformed;
public const string InvalidRingConsoleAlert = "Upgrade ring set to unknown value. " + NoUpgradeCheckPerformed;
public const string SetUpgradeRingCommand = "To set or change upgrade ring, run `gvfs config " + LocalGVFSConfig.UpgradeRing + " [\"Fast\"|\"Slow\"|\"None\"]` from a command prompt.";
public const string ReminderNotification = "A new version of GVFS is available. Run " + UpgradeVerbMessages.GVFSUpgradeConfirm + " from an elevated command prompt to upgrade.";
public const string UnmountRepoWarning = "Upgrade will unmount and remount gvfs repos, ensure you are at a stopping point.";
public const string UpgradeInstallAdvice = "When ready, run " + UpgradeVerbMessages.GVFSUpgradeConfirm + " from an elevated command prompt.";
}
}
}
4 changes: 4 additions & 0 deletions GVFS/GVFS.Common/GVFSPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ public abstract class GVFSPlatformConstants
/// the upgrade verb is running.
/// </summary>
public abstract bool SupportsUpgradeWhileRunning { get; }
public abstract string UpgradeInstallAdviceMessage { get; }
public abstract string RunUpdateMessage { get; }
public abstract string UpgradeConfirmCommandMessage { get; }
public abstract string StartServiceCommandMessage { get; }
public abstract string WorkingDirectoryBackingRootPath { get; }
public abstract string DotGVFSRoot { get; }

Expand Down
8 changes: 4 additions & 4 deletions GVFS/GVFS.Common/InstallerPreRunChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ protected virtual bool TryRunGVFSWithArgs(string args, out string consoleError)

private bool IsGVFSUpgradeAllowed(out string consoleError)
{
bool isConfirmed = string.Equals(this.CommandToRerun, GVFSConstants.UpgradeVerbMessages.GVFSUpgradeConfirm, StringComparison.OrdinalIgnoreCase);
bool isConfirmed = string.Equals(this.CommandToRerun, GVFSPlatform.Instance.Constants.UpgradeConfirmCommandMessage, StringComparison.OrdinalIgnoreCase);
string adviceText = null;
if (!this.IsElevated())
{
adviceText = isConfirmed ? $"Run {this.CommandToRerun} again from an elevated command prompt." : $"To install, run {GVFSConstants.UpgradeVerbMessages.GVFSUpgradeConfirm} from an elevated command prompt.";
jeschu1 marked this conversation as resolved.
Show resolved Hide resolved
adviceText = GVFSPlatform.Instance.Constants.RunUpdateMessage;
consoleError = string.Join(
Environment.NewLine,
"The installer needs to be run from an elevated command prompt.",
"The installer needs to be run with elevated permissions.",
adviceText);
this.tracer.RelatedWarning($"{nameof(this.IsGVFSUpgradeAllowed)}: Upgrade is not installable. {consoleError}");
return false;
Expand All @@ -202,7 +202,7 @@ private bool IsGVFSUpgradeAllowed(out string consoleError)

if (this.IsServiceInstalledAndNotRunning())
{
adviceText = isConfirmed ? $"Run `sc start GVFS.Service` and run {this.CommandToRerun} again from an elevated command prompt." : $"To install, run `sc start GVFS.Service` and run {GVFSConstants.UpgradeVerbMessages.GVFSUpgradeConfirm} from an elevated command prompt.";
adviceText = $"To install, run {GVFSPlatform.Instance.Constants.StartServiceCommandMessage} and run {GVFSPlatform.Instance.Constants.UpgradeConfirmCommandMessage}.";
consoleError = string.Join(
Environment.NewLine,
"GVFS Service is not running.",
Expand Down
2 changes: 1 addition & 1 deletion GVFS/GVFS.Common/ProductUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public virtual bool TrySetupUpgradeApplicationDirectory(out string upgradeApplic
error = string.Join(
Environment.NewLine,
"File copy error - " + e.Message,
$"Make sure you have write permissions to directory {upgradeApplicationDirectory} and run {GVFSConstants.UpgradeVerbMessages.GVFSUpgradeConfirm} again.");
$"Make sure you have write permissions to directory {upgradeApplicationDirectory} and run {GVFSPlatform.Instance.Constants.UpgradeConfirmCommandMessage} again.");
}
catch (IOException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private bool ReminderMessagingEnabled()
removeUpgradeMessages: false);

if (!string.IsNullOrEmpty(result.Errors) &&
result.Errors.Contains("A new version of GVFS is available."))
result.Errors.Contains("A new version of VFS for Git is available."))
{
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions GVFS/GVFS.Hooks/HooksPlatform/GVFSHooksPlatform.Mac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ public static string GetGitGuiBlockedMessage()
{
return "git gui is not supported in VFS for Git repos on Mac";
}

public static string GetUpgradeReminderNotification()
{
return MacPlatform.GetUpgradeReminderNotificationImplementation();
}
}
}
5 changes: 5 additions & 0 deletions GVFS/GVFS.Hooks/HooksPlatform/GVFSHooksPlatform.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@ public static string GetGitGuiBlockedMessage()
{
return "To access the 'git gui' in a GVFS repo, please invoke 'git-gui.exe' instead.";
}

public static string GetUpgradeReminderNotification()
{
return WindowsPlatform.GetUpgradeReminderNotificationImplementation();
}
}
}
2 changes: 1 addition & 1 deletion GVFS/GVFS.Hooks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static void RemindUpgradeAvailable()
if ((IsUpgradeMessageDeterministic() || randomValue <= reminderFrequency) &&
ProductUpgraderInfo.IsLocalUpgradeAvailable(tracer: null, highestAvailableVersionDirectory: GVFSHooksPlatform.GetUpgradeHighestAvailableVersionDirectory()))
{
Console.WriteLine(Environment.NewLine + GVFSConstants.UpgradeVerbMessages.ReminderNotification);
Console.WriteLine(Environment.NewLine + GVFSHooksPlatform.GetUpgradeReminderNotification());
}
}

Expand Down
6 changes: 6 additions & 0 deletions GVFS/GVFS.Platform.Mac/MacPlatform.Shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace GVFS.Platform.Mac
public partial class MacPlatform
{
public const string DotGVFSRoot = ".gvfs";
public const string UpgradeConfirmMessage = "`sudo gvfs upgrade --confirm`";

public static string GetDataRootForGVFSImplementation()
{
Expand Down Expand Up @@ -42,6 +43,11 @@ public static string GetNamedPipeNameImplementation(string enlistmentRoot)
{
return POSIXPlatform.GetNamedPipeNameImplementation(enlistmentRoot, DotGVFSRoot);
}

public static string GetUpgradeReminderNotificationImplementation()
{
return $"A new version of VFS for Git is available. Run {UpgradeConfirmMessage} to upgrade.";
}

private string GetUpgradeNonProtectedDataDirectory()
{
Expand Down
20 changes: 20 additions & 0 deletions GVFS/GVFS.Platform.Mac/MacPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,26 @@ public override string GVFSBinDirectoryName

// Documented here (in the addressing section): https://www.unix.com/man-page/mojave/4/unix/
public override int MaxPipePathLength => 104;

public override string UpgradeInstallAdviceMessage
{
get { return $"When ready, run {this.UpgradeConfirmCommandMessage} to upgrade."; }
}

public override string UpgradeConfirmCommandMessage
{
get { return UpgradeConfirmMessage; }
}

public override string StartServiceCommandMessage
{
get { return "`launchctl load /Library/LaunchAgents/org.vfsforgit.service.plist`"; }
}

public override string RunUpdateMessage
{
get { return $"Run {UpgradeConfirmMessage}."; }
}
}
}
}
6 changes: 6 additions & 0 deletions GVFS/GVFS.Platform.Windows/WindowsPlatform.Shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace GVFS.Platform.Windows
public partial class WindowsPlatform
{
public const string DotGVFSRoot = ".gvfs";
public const string UpgradeConfirmMessage = "`gvfs upgrade --confirm`";

private const int StillActive = 259; /* from Win32 STILL_ACTIVE */

Expand Down Expand Up @@ -121,6 +122,11 @@ public static string GetUpgradeHighestAvailableVersionDirectoryImplementation()
return GetUpgradeProtectedDataDirectoryImplementation();
}

public static string GetUpgradeReminderNotificationImplementation()
{
return $"A new version of VFS for Git is available. Run {UpgradeConfirmMessage} from an elevated command prompt to upgrade.";
}

[DllImport("kernel32.dll")]
private static extern IntPtr GetStdHandle(StdHandle std);

Expand Down
20 changes: 20 additions & 0 deletions GVFS/GVFS.Platform.Windows/WindowsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,26 @@ public override HashSet<string> UpgradeBlockingProcesses

// Tests show that 250 is the max supported pipe name length
public override int MaxPipePathLength => 250;

public override string UpgradeInstallAdviceMessage
{
get { return $"When ready, run {this.UpgradeConfirmCommandMessage} from an elevated command prompt."; }
}

public override string UpgradeConfirmCommandMessage
{
get { return UpgradeConfirmMessage; }
}

public override string StartServiceCommandMessage
{
get { return $"`sc start GVFS.Service`"; }
}

public override string RunUpdateMessage
{
get { return $"Run {UpgradeConfirmMessage} from an elevated command prompt."; }
}
}
}
}
10 changes: 5 additions & 5 deletions GVFS/GVFS.UnitTests.Windows/Windows/Upgrader/UpgradeVerbTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void UpgradeAvailabilityReporting()
expectedOutput: new List<string>
{
"New GVFS version " + NewerThanLocalVersion + " available in ring Slow",
"When ready, run `gvfs upgrade --confirm` from an elevated command prompt."
"MockUpgradeInstallAdvice"
},
expectedErrors: null);
}
Expand Down Expand Up @@ -166,7 +166,7 @@ public void IsGVFSServiceRunningPreCheck()
expectedOutput: new List<string>
{
"GVFS Service is not running.",
"Run `sc start GVFS.Service` and run `gvfs upgrade --confirm` again from an elevated command prompt."
"To install, run MockStartServiceCommand and run MockUpgradeConfirmCommand."
},
expectedErrors: null,
expectedWarnings: new List<string>
Expand All @@ -188,13 +188,13 @@ public void ElevatedRunPreCheck()
expectedReturn: ReturnCode.GenericError,
expectedOutput: new List<string>
{
"The installer needs to be run from an elevated command prompt.",
"Run `gvfs upgrade --confirm` again from an elevated command prompt."
"The installer needs to be run with elevated permissions.",
"MockRunUpdateMessage"
},
expectedErrors: null,
expectedWarnings: new List<string>
{
"The installer needs to be run from an elevated command prompt."
"The installer needs to be run with elevated permissions."
});
}

Expand Down
20 changes: 20 additions & 0 deletions GVFS/GVFS.UnitTests/Mock/Common/MockPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,26 @@ public override HashSet<string> UpgradeBlockingProcesses
public override bool SupportsUpgradeWhileRunning => false;

public override int MaxPipePathLength => 250;

public override string UpgradeInstallAdviceMessage
{
get { return "MockUpgradeInstallAdvice"; }
}

public override string UpgradeConfirmCommandMessage
{
get { return "MockUpgradeConfirmCommand"; }
}

public override string StartServiceCommandMessage
{
get { return "MockStartServiceCommand"; }
}

public override string RunUpdateMessage
{
get { return "MockRunUpdateMessage"; }
}
}
}
}
2 changes: 1 addition & 1 deletion GVFS/GVFS.Upgrader/UpgradeOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void Execute()

if (this.preRunChecker == null)
{
this.preRunChecker = new InstallerPreRunChecker(this.tracer, GVFSConstants.UpgradeVerbMessages.GVFSUpgradeConfirm);
this.preRunChecker = new InstallerPreRunChecker(this.tracer, GVFSPlatform.Instance.Constants.UpgradeConfirmCommandMessage);
}

try
Expand Down
4 changes: 2 additions & 2 deletions GVFS/GVFS/CommandLine/UpgradeVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private bool TryInitializeUpgrader(out string error)
jsonTracer.AddLogFileEventListener(logFilePath, EventLevel.Informational, Keywords.Any);

this.tracer = jsonTracer;
this.prerunChecker = new InstallerPreRunChecker(this.tracer, this.Confirmed ? GVFSConstants.UpgradeVerbMessages.GVFSUpgradeConfirm : GVFSConstants.UpgradeVerbMessages.GVFSUpgrade);
this.prerunChecker = new InstallerPreRunChecker(this.tracer, this.Confirmed ? GVFSPlatform.Instance.Constants.UpgradeConfirmCommandMessage : GVFSConstants.UpgradeVerbMessages.GVFSUpgrade);

string gitBinPath = GVFSPlatform.Instance.GitInstallation.GetInstalledGitBinPath();
if (string.IsNullOrEmpty(gitBinPath))
Expand Down Expand Up @@ -210,7 +210,7 @@ private bool TryRunProductUpgrade()
string advisoryMessage = string.Join(
Environment.NewLine,
GVFSConstants.UpgradeVerbMessages.UnmountRepoWarning,
GVFSConstants.UpgradeVerbMessages.UpgradeInstallAdvice);
GVFSPlatform.Instance.Constants.UpgradeInstallAdviceMessage);
this.ReportInfoToConsole(message + Environment.NewLine + Environment.NewLine + advisoryMessage + Environment.NewLine);
}

Expand Down