Skip to content

Commit

Permalink
ScalarEnlistment: properly store working directory when creating with…
Browse files Browse the repository at this point in the history
…out URL

Remove the other constructor that allows this by default to avoid this
problem in the future.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
derrickstolee committed Mar 17, 2020
1 parent 0827468 commit e1b2a97
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Scalar.Common/InvalidRepoException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class InvalidRepoException : Exception
public string RepoPath { get; }

public InvalidRepoException(string repoPath, string message)
: base(message)
: base($"path: '{repoPath}', message: '{message}'")
{
this.RepoPath = repoPath;
}
Expand Down
16 changes: 2 additions & 14 deletions Scalar.Common/ScalarEnlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,7 @@ public partial class ScalarEnlistment : Enlistment
private string gitVersion;
private string scalarVersion;

// New enlistment
public ScalarEnlistment(string enlistmentRoot, string repoUrl, string gitBinPath, GitAuthentication authentication)
: this(
enlistmentRoot,
Path.Combine(enlistmentRoot, ScalarConstants.WorkingDirectoryRootName),
repoUrl,
gitBinPath,
authentication)
{
}

// Existing, configured enlistment
private ScalarEnlistment(string enlistmentRoot, string workingDirectory, string repoUrl, string gitBinPath, GitAuthentication authentication)
public ScalarEnlistment(string enlistmentRoot, string workingDirectory, string repoUrl, string gitBinPath, GitAuthentication authentication)
: base(
enlistmentRoot,
workingDirectory,
Expand Down Expand Up @@ -74,7 +62,7 @@ public static ScalarEnlistment CreateFromDirectory(

if (createWithoutRepoURL)
{
return new ScalarEnlistment(enlistmentRoot, string.Empty, gitBinRoot, authentication);
return new ScalarEnlistment(enlistmentRoot, workingDirectory, string.Empty, gitBinRoot, authentication);
}

return new ScalarEnlistment(enlistmentRoot, workingDirectory, null, gitBinRoot, authentication);
Expand Down
2 changes: 1 addition & 1 deletion Scalar.UnitTests/Common/ScalarEnlistmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private class TestScalarEnlistment : ScalarEnlistment
private MockGitProcess gitProcess;

public TestScalarEnlistment()
: base("mock:\\path", "mock://repoUrl", "mock:\\git", authentication: null)
: base("mock:\\path", "mock:\\path", "mock://repoUrl", "mock:\\git", authentication: null)
{
this.gitProcess = new MockGitProcess();
this.gitProcess.SetExpectedCommandResult(
Expand Down
4 changes: 2 additions & 2 deletions Scalar.UnitTests/Mock/Common/MockScalarEnlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public class MockScalarEnlistment : ScalarEnlistment
private MockGitProcess gitProcess;

public MockScalarEnlistment()
: base(Path.Combine("mock:", "path"), "mock://repoUrl", Path.Combine("mock:", "git"), authentication: null)
: base(Path.Combine("mock:", "path"), Path.Combine("mock:", "path"), "mock://repoUrl", Path.Combine("mock:", "git"), authentication: null)
{
this.GitObjectsRoot = Path.Combine("mock:", "path", ".git", "objects");
this.LocalObjectsRoot = this.GitObjectsRoot;
this.GitPackRoot = Path.Combine("mock:", "path", ".git", "objects", "pack");
}

public MockScalarEnlistment(string enlistmentRoot, string repoUrl, string gitBinPath, MockGitProcess gitProcess)
: base(enlistmentRoot, repoUrl, gitBinPath, authentication: null)
: base(enlistmentRoot, enlistmentRoot, repoUrl, gitBinPath, authentication: null)
{
this.gitProcess = gitProcess;
}
Expand Down

0 comments on commit e1b2a97

Please sign in to comment.