Skip to content

Commit 8dfab60

Browse files
committed
GitRepoTests: move extra setup into CreateEnlistment()
Some subclasses of GitRepoTests override CreateEnlistment so they can do extra steps after the base class creates the repo. However, those steps happen between the base CreateEnlistment() and the rest of the TestSetup code. This started failing with the v2.28.0 upgrade because 'git status' started reporting new info about sparse-checkouts. Move the sparse-checkout setup code into CreateEnlistment() to stop failures. Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
1 parent 32a1a1c commit 8dfab60

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

Scalar.FunctionalTests/Tests/GitCommands/GitRepoTests.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,6 @@ public virtual void SetupForTest()
132132
this.CreateEnlistment();
133133
}
134134

135-
if (this.validateWorkingTree == Settings.ValidateWorkingTreeMode.SparseMode)
136-
{
137-
StringBuilder sb = new StringBuilder();
138-
139-
foreach (string folder in SparseModeFolders)
140-
{
141-
sb.Append(folder.Replace(Path.DirectorySeparatorChar, TestConstants.GitPathSeparator)
142-
.Trim(TestConstants.GitPathSeparator));
143-
sb.Append("\n");
144-
}
145-
146-
GitProcess.InvokeProcess(this.ControlGitRepo.RootPath, "sparse-checkout init --cone", string.Empty);
147-
GitProcess.InvokeProcess(this.ControlGitRepo.RootPath, "sparse-checkout set --stdin", sb.ToString());
148-
149-
// This line shouldn't be necessary!
150-
GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "sparse-checkout init --cone", string.Empty);
151-
GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "sparse-checkout set --stdin", sb.ToString());
152-
this.pathPrefixes = SparseModeFolders;
153-
}
154-
155135
this.ValidateGitCommand("checkout " + this.ControlGitRepo.Commitish);
156136

157137
this.CheckHeadCommitTree();
@@ -221,6 +201,26 @@ protected void CreateEnlistment(string commitish = null)
221201
GitProcess.Invoke(this.Enlistment.RepoRoot, "config advice.statusUoption false");
222202
this.ControlGitRepo = ControlGitRepo.Create(commitish);
223203
this.ControlGitRepo.Initialize();
204+
205+
if (this.validateWorkingTree == Settings.ValidateWorkingTreeMode.SparseMode)
206+
{
207+
StringBuilder sb = new StringBuilder();
208+
209+
foreach (string folder in SparseModeFolders)
210+
{
211+
sb.Append(folder.Replace(Path.DirectorySeparatorChar, TestConstants.GitPathSeparator)
212+
.Trim(TestConstants.GitPathSeparator));
213+
sb.Append("\n");
214+
}
215+
216+
GitProcess.InvokeProcess(this.ControlGitRepo.RootPath, "sparse-checkout init --cone", string.Empty);
217+
GitProcess.InvokeProcess(this.ControlGitRepo.RootPath, "sparse-checkout set --stdin", sb.ToString());
218+
219+
// This line shouldn't be necessary!
220+
GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "sparse-checkout init --cone", string.Empty);
221+
GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "sparse-checkout set --stdin", sb.ToString());
222+
this.pathPrefixes = SparseModeFolders;
223+
}
224224
}
225225

226226
protected virtual void DeleteEnlistment()

0 commit comments

Comments
 (0)