Skip to content
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
10 changes: 9 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@

<!-- Version information -->
<ScalarVersion>0.2.173.2</ScalarVersion>
<GitPackageVersion>2.20200227.1</GitPackageVersion>

<!--
Update the GitPackageVersion for the version that is shipped and tested with Scalar.
The MinimumGitVersion is intentionally lower to allow side-by-side installs of
VFS for Git (which is less flexible). Only update that version if we rely upon a
new command-line interface in Git or if there is a truly broken interaction.
-->
<GitPackageVersion>2.20200323.8</GitPackageVersion>
<MinimumGitVersion>v2.25.0.vfs.1.1</MinimumGitVersion>
Comment thread
derrickstolee marked this conversation as resolved.

<WatchmanPackageUrl>https://github.com/facebook/watchman/suites/307436006/artifacts/304557</WatchmanPackageUrl>
<GcmCoreOSXPackageUrl>https://github.com/microsoft/Git-Credential-Manager-Core/releases/download/v2.0.79-beta/gcmcore-osx-2.0.79.64449.pkg</GcmCoreOSXPackageUrl>

Expand Down
18 changes: 15 additions & 3 deletions Scalar.Common/Maintenance/ConfigStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,18 @@ private void ConfigureWatchmanIntegration()

try
{
string hooksDir = ScalarPlatform.Instance.GetTemplateHooksDirectory();

if (string.IsNullOrEmpty(hooksDir))
{
this.Context.Tracer.RelatedError("Could not find hook templates directory. Skipping watchman integration.");
return;
}

// Install query-watchman hook from latest Git path
string fsMonitorWatchmanSampleHookPath = Path.Combine(
this.Context.Enlistment.WorkingDirectoryRoot,
ScalarConstants.DotGit.Hooks.FsMonitorWatchmanSamplePath);
hooksDir,
ScalarConstants.DotGit.Hooks.FsMonitorWatchmanSampleName);

string queryWatchmanPath = Path.Combine(
this.Context.Enlistment.WorkingDirectoryRoot,
Expand All @@ -250,7 +259,10 @@ private void ConfigureWatchmanIntegration()

string dotGitRoot = this.Context.Enlistment.DotGitRoot.Replace(Path.DirectorySeparatorChar, ScalarConstants.GitPathSeparator);
this.RunGitCommand(
process => process.SetInLocalConfig("core.fsmonitor", dotGitRoot + "/hooks/query-watchman"),
process => process.SetInLocalConfig("core.fsmonitor", dotGitRoot + "/hooks/query-watchman"),
"config");
this.RunGitCommand(
process => process.SetInLocalConfig("core.fsmonitorHookVersion", "2"),
"config");

this.Context.Tracer.RelatedInfo("Watchman configured!");
Expand Down
5 changes: 5 additions & 0 deletions Scalar.Common/Platforms/Mac/MacPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ public override void IsServiceInstalledAndRunning(string name, out bool installe
running = installed && scalarService.IsRunning;
}

public override string GetTemplateHooksDirectory()
{
return Path.Combine("usr", "local", ScalarConstants.InstalledGit.HookTemplateDir);
}

public class MacPlatformConstants : POSIXPlatformConstants
{
public override string InstallerExtension
Expand Down
14 changes: 14 additions & 0 deletions Scalar.Common/Platforms/Windows/WindowsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,20 @@ public override ProductUpgraderPlatformStrategy CreateProductUpgraderPlatformInt
return new WindowsProductUpgraderPlatformStrategy(fileSystem, tracer);
}

public override string GetTemplateHooksDirectory()
{
string gitBinPath = GitInstallation.GetInstalledGitBinPath();

string tail = Path.Combine("cmd", "git.exe");
if (gitBinPath.EndsWith(tail))
{
string gitBasePath = gitBinPath.Substring(0, gitBinPath.Length - tail.Length);
return Path.Combine(gitBasePath, "mingw64", ScalarConstants.InstalledGit.HookTemplateDir);
}

return null;
}

public override bool TryGetDefaultLocalCacheRoot(string enlistmentRoot, out string localCacheRoot, out string localCacheRootError)
{
string pathRoot;
Expand Down
5 changes: 5 additions & 0 deletions Scalar.Common/ScalarConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ public static class Hidden
}
}

public static class InstalledGit
{
public static readonly string HookTemplateDir = Path.Combine("share", "git-core", "templates", "hooks");
}

public static class VerbParameters
{
public const string InternalUseOnly = "internal_use_only";
Expand Down
2 changes: 2 additions & 0 deletions Scalar.Common/ScalarPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public abstract ProductUpgraderPlatformStrategy CreateProductUpgraderPlatformInt
PhysicalFileSystem fileSystem,
ITracer tracer);

public abstract string GetTemplateHooksDirectory();

public bool TryGetNormalizedPathRoot(string path, out string pathRoot, out string errorMessage)
{
pathRoot = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ public void OpenFileThenCheckout()
string command = "checkout -b tests/functional/OpenFileThenCheckout_2";
ProcessResult expectedResult = GitProcess.InvokeProcess(controlRepoRoot, command);
ProcessResult actualResult = GitHelpers.InvokeGitAgainstScalarRepo(scalarRepoRoot, command);
GitHelpers.ErrorsShouldMatch(command, expectedResult, actualResult);
GitHelpers.LinesShouldMatch(command, expectedResult.Errors, actualResult.Errors);
actualResult.Errors.ShouldContain("Switched to a new branch");

this.ValidateGitCommand("status");
Expand Down
3 changes: 2 additions & 1 deletion Scalar.FunctionalTests/Tests/GitCommands/GitRepoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ protected void CreateEnlistment(string commitish = null)
ScalarTestConfig.PathToScalar,
commitish: commitish,
fullClone: this.validateWorkingTree != Settings.ValidateWorkingTreeMode.SparseMode);
GitProcess.Invoke(this.Enlistment.RepoRoot, "config core.editor true");
GitProcess.Invoke(this.Enlistment.RepoRoot, "config advice.statusUoption false");
this.ControlGitRepo = ControlGitRepo.Create(commitish);
this.ControlGitRepo.Initialize();
Expand Down Expand Up @@ -261,7 +262,7 @@ protected void RunGitCommand(string command, bool ignoreErrors = false, bool che

if (!ignoreErrors)
{
GitHelpers.ErrorsShouldMatch(command, expectedResult, actualResult);
GitHelpers.LinesShouldMatch(command, expectedResult.Errors, actualResult.Errors);
}

if (command != "status" && checkStatus)
Expand Down
3 changes: 1 addition & 2 deletions Scalar.FunctionalTests/Tools/ControlGitRepo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Scalar.FunctionalTests.FileSystemRunners;
using System;
using System.IO;
using System.Runtime.InteropServices;

namespace Scalar.FunctionalTests.Tools
{
Expand Down Expand Up @@ -52,6 +50,7 @@ public void Initialize()
Directory.CreateDirectory(this.RootPath);
GitProcess.Invoke(this.RootPath, "init");
GitProcess.Invoke(this.RootPath, "config core.autocrlf false");
GitProcess.Invoke(this.RootPath, "config core.editor true");
GitProcess.Invoke(this.RootPath, "config merge.stat false");
GitProcess.Invoke(this.RootPath, "config merge.renames false");
GitProcess.Invoke(this.RootPath, "config advice.statusUoption false");
Expand Down
20 changes: 14 additions & 6 deletions Scalar.FunctionalTests/Tools/GitHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,32 @@ public static void ValidateGitCommand(

Dictionary<string, string> environmentVariables = new Dictionary<string, string>();
environmentVariables["GIT_QUIET"] = "true";
environmentVariables["GIT_COMMITTER_DATE"] = "Thu Feb 16 10:07:35 2017 -0700";

ProcessResult expectedResult = GitProcess.InvokeProcess(controlRepoRoot, command, environmentVariables);
ProcessResult actualResult = GitHelpers.InvokeGitAgainstScalarRepo(scalarRepoRoot, command, environmentVariables);

ErrorsShouldMatch(command, expectedResult, actualResult);
actualResult.Output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
.ShouldMatchInOrder(expectedResult.Output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries), LinesAreEqual, command + " Output Lines");
LinesShouldMatch(command + " Errors Lines", actualResult.Errors, expectedResult.Errors);
LinesShouldMatch(command + " Output Lines", actualResult.Output, expectedResult.Output);

if (command != "status")
{
ValidateGitCommand(enlistment, controlGitRepo, "status");
}
}

public static void ErrorsShouldMatch(string command, ProcessResult expectedResult, ProcessResult actualResult)
public static void LinesShouldMatch(string message, string expected, string actual)
{
actualResult.Errors.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
.ShouldMatchInOrder(expectedResult.Errors.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries), LinesAreEqual, command + " Errors Lines");
IEnumerable<string> actualLines = NonEmptyLines(actual);
IEnumerable<string> expectedLines = NonEmptyLines(expected);
actualLines.ShouldMatchInOrder(expectedLines, LinesAreEqual, message);
}

private static IEnumerable<string> NonEmptyLines(string data)
{
return data
.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
.Where(s => !string.IsNullOrWhiteSpace(s));
}

private static bool LinesAreEqual(string actualLine, string expectedLine)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ private static IEnumerable<T> ShouldMatch<T>(this IEnumerable<T> group, IEnumera

foreach (T groupExtraItem in groupExtraItems)
{
errorMessage.AppendLine(string.Format("Extra: {0}", groupExtraItem));
errorMessage.AppendLine(string.Format("Extra: '{0}'", groupExtraItem));
}

foreach (T groupMissingItem in groupMissingItems)
{
errorMessage.AppendLine(string.Format("Missing: {0}", groupMissingItem));
errorMessage.AppendLine(string.Format("Missing: '{0}'", groupMissingItem));
}

if (shouldMatchInOrder)
Expand All @@ -150,7 +150,7 @@ private static IEnumerable<T> ShouldMatch<T>(this IEnumerable<T> group, IEnumera
{
if (!equals(groupList[i], expectedValuesList[i]))
{
errorMessage.AppendLine($"Items ordered differently, found: {groupList[i]} expected: {expectedValuesList[i]}");
errorMessage.AppendLine($"Items ordered differently, found: '{groupList[i]}' expected: '{expectedValuesList[i]}'");
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Scalar.UnitTests/Mock/Common/MockPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public override bool TryKillProcessTree(int processId, out int exitCode, out str
return true;
}

public override string GetTemplateHooksDirectory()
{
throw new NotSupportedException();
}

public class MockPlatformConstants : ScalarPlatformConstants
{
public override string ExecutableExtension
Expand Down