public void LockToPreventDelete_SingleFile() { string testFile1Contents = "TestContentsLockToPreventDelete \r\n"; string testFile1Name = "test.txt"; string testFile1Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventDelete", testFile1Name)); testFile1Path.ShouldBeAFile(this.fileSystem).WithContents(testFile1Contents); using (SafeFileHandle testFile1Handle = this.CreateFile(testFile1Path, FileShare.Read)) { testFile1Handle.IsInvalid.ShouldEqual(false); ProcessResult result = this.InvokeGitAgainstGSDRepo("checkout " + OldCommitId); result.Errors.ShouldContain( "GSD was unable to delete the following files. To recover, close all handles to the files and run these commands:", "git clean -f " + TestParentFolderName + "/LockToPreventDelete/" + testFile1Name); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status -u", "HEAD detached at " + OldCommitId, "Untracked files:", TestParentFolderName + "/LockToPreventDelete/" + testFile1Name); } this.GitCleanFile(TestParentFolderName + "/LockToPreventDelete/" + testFile1Name); this.GitStatusShouldBeClean(OldCommitId); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventDelete/" + testFile1Name); testFile1Path.ShouldNotExistOnDisk(this.fileSystem); this.GitCheckoutCommitId(NewFilesAndChangesCommitId); this.GitStatusShouldBeClean(NewFilesAndChangesCommitId); testFile1Path.ShouldBeAFile(this.fileSystem).WithContents(testFile1Contents); }
public void GitStatusAndObjectAfterGitAdd() { string existingFilename = "test.cs"; this.Enlistment.GetVirtualPathTo(existingFilename).ShouldBeAFile(this.fileSystem); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "add " + existingFilename, new string[] { }); // Status should be correct GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch " + Properties.Settings.Default.Commitish, "Changes to be committed:", existingFilename); // Object file for the test file should have the correct contents ProcessResult result = GitHelpers.InvokeGitAgainstGSDRepo( this.Enlistment.RepoRoot, "hash-object " + existingFilename); string objectHash = result.Output.Trim(); result.Errors.ShouldBeEmpty(); this.Enlistment.GetObjectPathTo(objectHash).ShouldBeAFile(this.fileSystem); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "cat-file -p " + objectHash, this.testFileContents); }
private void GitCleanFile(string gitPath) { GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "clean -f " + gitPath, "Removing " + gitPath); }
public void GitStatusReportsSymLinkChanges() { GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20180925_SymLinksPart4", "nothing to commit, working tree clean"); string testFilePath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFileName)); testFilePath.ShouldBeAFile(this.bashRunner).WithContents(GrandChildFileContents); this.bashRunner.IsSymbolicLink(testFilePath).ShouldBeTrue($"{testFilePath} should be a symlink"); string testFile2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFile2Name)); testFile2Path.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); this.bashRunner.IsSymbolicLink(testFile2Path).ShouldBeFalse($"{testFile2Path} should not be a symlink"); // Update testFilePath's symlink to point to testFile2Path this.bashRunner.CreateSymbolicLink(testFilePath, testFile2Path); testFilePath.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); this.bashRunner.IsSymbolicLink(testFilePath).ShouldBeTrue($"{testFilePath} should be a symlink"); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20180925_SymLinksPart4", $"modified: {TestFolderName}/{TestFileName}"); }
public void GitStatusAfterRenameFolderIntoRepo() { string folderName = "GitStatusAfterRenameFolderIntoRepo"; // Create the test folder in this.Enlistment.EnlistmentRoot as it's outside of src // and is cleaned up when the functional tests run string folderPath = Path.Combine(this.Enlistment.EnlistmentRoot, folderName); this.fileSystem.CreateDirectory(folderPath); string fileName = "GitStatusAfterRenameFolderIntoRepo_file.txt"; string filePath = Path.Combine(folderPath, fileName); this.fileSystem.WriteAllText(filePath, this.testFileContents); filePath.ShouldBeAFile(this.fileSystem).WithContents(this.testFileContents); this.fileSystem.MoveDirectory(folderPath, this.Enlistment.GetVirtualPathTo(folderName)); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status -uall", "On branch " + Properties.Settings.Default.Commitish, "Untracked files:", folderName + "/", folderName + "/" + fileName); }
public void GitStatusAfterRenameFileIntoRepo() { string filename = "GitStatusAfterRenameFileIntoRepo.cs"; // Create the test file in this.Enlistment.EnlistmentRoot as it's outside of src // and is cleaned up when the functional tests run string filePath = Path.Combine(this.Enlistment.EnlistmentRoot, filename); this.fileSystem.WriteAllText(filePath, this.testFileContents); filePath.ShouldBeAFile(this.fileSystem).WithContents(this.testFileContents); string renamedFileName = Path.Combine("GVFlt_MoveFileTest", "GitStatusAfterRenameFileIntoRepo.cs"); string renamedFilePath = this.Enlistment.GetVirtualPathTo(renamedFileName); this.fileSystem.MoveFile(filePath, renamedFilePath); filePath.ShouldNotExistOnDisk(this.fileSystem); renamedFilePath.ShouldBeAFile(this.fileSystem); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch " + Properties.Settings.Default.Commitish, "Untracked files:", renamedFileName.Replace('\\', '/')); }
public void CheckoutBranchWithSymLinks() { GitHelpers.InvokeGitAgainstGSDRepo(this.Enlistment.RepoRoot, "checkout FunctionalTests/20180925_SymLinksPart1"); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20180925_SymLinksPart1", "nothing to commit, working tree clean"); string testFilePath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFileName)); testFilePath.ShouldBeAFile(this.bashRunner).WithContents(TestFileContents); this.bashRunner.IsSymbolicLink(testFilePath).ShouldBeFalse($"{testFilePath} should not be a symlink"); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + TestFileName); string testFile2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFile2Name)); testFile2Path.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); this.bashRunner.IsSymbolicLink(testFile2Path).ShouldBeFalse($"{testFile2Path} should not be a symlink"); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + TestFile2Name); string childLinkPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildLinkName)); this.bashRunner.IsSymbolicLink(childLinkPath).ShouldBeTrue($"{childLinkPath} should be a symlink"); childLinkPath.ShouldBeAFile(this.bashRunner).WithContents(TestFileContents); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildLinkName); string grandChildLinkPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildFolderName, GrandChildLinkName)); this.bashRunner.IsSymbolicLink(grandChildLinkPath).ShouldBeTrue($"{grandChildLinkPath} should be a symlink"); grandChildLinkPath.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildFolderName + "/" + GrandChildLinkName); }
public void GitStatus() { GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch " + Properties.Settings.Default.Commitish, "nothing to commit, working tree clean"); }
private void GitStatusShouldBeClean(string commitId) { GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "HEAD detached at " + commitId, "nothing to commit, working tree clean"); }
public void GitStatusAfterFileDelete() { string existingFilename = "test.cs"; this.EnsureTestFileExists(existingFilename); this.fileSystem.DeleteFile(this.Enlistment.GetVirtualPathTo(existingFilename)); this.Enlistment.GetVirtualPathTo(existingFilename).ShouldNotExistOnDisk(this.fileSystem); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch " + Properties.Settings.Default.Commitish, "nothing to commit, working tree clean"); }
public void CheckoutBranchWhereFilesTransitionToSymLinks() { GitHelpers.InvokeGitAgainstGSDRepo(this.Enlistment.RepoRoot, "checkout FunctionalTests/20180925_SymLinksPart3"); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20180925_SymLinksPart3", "nothing to commit, working tree clean"); // In this branch testFilePath has been changed to point to newGrandChildFilePath string testFilePath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFileName)); testFilePath.ShouldBeAFile(this.bashRunner).WithContents(GrandChildFileContents); this.bashRunner.IsSymbolicLink(testFilePath).ShouldBeTrue($"{testFilePath} should be a symlink"); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + TestFileName); // There should be a new ChildFolder2Name directory string childFolder2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildFolder2Name)); this.bashRunner.IsSymbolicLink(childFolder2Path).ShouldBeFalse($"{childFolder2Path} should not be a symlink"); childFolder2Path.ShouldBeADirectory(this.bashRunner); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildFolder2Name); // The rest of the files are unchanged from FunctionalTests/20180925_SymLinksPart2 string testFile2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFile2Name)); testFile2Path.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); this.bashRunner.IsSymbolicLink(testFile2Path).ShouldBeFalse($"{testFile2Path} should not be a symlink"); string childLinkPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildLinkName)); this.bashRunner.IsSymbolicLink(childLinkPath).ShouldBeTrue($"{childLinkPath} should be a symlink"); childLinkPath.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildLinkName); string grandChildLinkPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildFolderName, GrandChildLinkName)); this.bashRunner.IsSymbolicLink(grandChildLinkPath).ShouldBeFalse($"{grandChildLinkPath} should not be a symlink"); grandChildLinkPath.ShouldBeAFile(this.bashRunner).WithContents(GrandChildLinkNowAFileContents); string newGrandChildFilePath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildFolderName, GrandChildFileName)); newGrandChildFilePath.ShouldBeAFile(this.bashRunner).WithContents(GrandChildFileContents); this.bashRunner.IsSymbolicLink(newGrandChildFilePath).ShouldBeFalse($"{newGrandChildFilePath} should not be a symlink"); }
public void GitStatusAfterFileRename() { string oldFilename = "New.cs"; this.EnsureTestFileExists(oldFilename); string newFilename = "test.cs"; string newFilePath = this.Enlistment.GetVirtualPathTo(newFilename); this.fileSystem.MoveFile(this.Enlistment.GetVirtualPathTo(oldFilename), newFilePath); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch " + Properties.Settings.Default.Commitish, "Untracked files:", newFilename); }
public void GitStatusAfterUnstage() { string existingFilename = "test.cs"; this.Enlistment.GetVirtualPathTo(existingFilename).ShouldBeAFile(this.fileSystem); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "reset HEAD " + existingFilename, new string[] { }); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch " + Properties.Settings.Default.Commitish, "Untracked files:", existingFilename); }
public void GitStatusAfterNewFile() { string filename = "new.cs"; string filePath = this.Enlistment.GetVirtualPathTo(filename); filePath.ShouldNotExistOnDisk(this.fileSystem); this.fileSystem.WriteAllText(filePath, this.testFileContents); filePath.ShouldBeAFile(this.fileSystem).WithContents(this.testFileContents); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch " + Properties.Settings.Default.Commitish, "Untracked files:", filename); this.fileSystem.DeleteFile(filePath); }
public void CheckoutBranchWhereSymLinkTransistionsToFolderAndFolderTransitionsToSymlink() { GitHelpers.InvokeGitAgainstGSDRepo(this.Enlistment.RepoRoot, "checkout FunctionalTests/20180925_SymLinksPart4"); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20180925_SymLinksPart4", "nothing to commit, working tree clean"); // In this branch ChildLinkName has been changed to a directory and ChildFolder2Name has been changed to a link to ChildFolderName string linkNowADirectoryPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildLinkName)); this.bashRunner.IsSymbolicLink(linkNowADirectoryPath).ShouldBeFalse($"{linkNowADirectoryPath} should not be a symlink"); linkNowADirectoryPath.ShouldBeADirectory(this.bashRunner); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildLinkName); string directoryNowALinkPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildFolder2Name)); this.bashRunner.IsSymbolicLink(directoryNowALinkPath).ShouldBeTrue($"{directoryNowALinkPath} should be a symlink"); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildFolder2Name); }
public void LockToPreventUpdateAndDelete() { string testFileUpdate1Contents = "Commit2LockToPreventUpdateAndDelete \r\n"; string testFileUpdate2Contents = "Commit2LockToPreventUpdateAndDelete2 \r\n"; string testFileUpdate3Contents = "Commit2LockToPreventUpdateAndDelete3 \r\n"; string testFileDelete1Contents = "PreventDelete \r\n"; string testFileDelete2Contents = "PreventDelete2 \r\n"; string testFileDelete3Contents = "PreventDelete3 \r\n"; string testFileUpdate1OldContents = "TestFileLockToPreventUpdateAndDelete \r\n"; string testFileUpdate2OldContents = "TestFileLockToPreventUpdateAndDelete2 \r\n"; string testFileUpdate3OldContents = "TestFileLockToPreventUpdateAndDelete3 \r\n"; string testFileUpdate1Name = "test.txt"; string testFileUpdate2Name = "test2.txt"; string testFileUpdate3Name = "test3.txt"; string testFileDelete1Name = "test_delete.txt"; string testFileDelete2Name = "test_delete2.txt"; string testFileDelete3Name = "test_delete3.txt"; string testFileUpdate1Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdateAndDelete", testFileUpdate1Name)); string testFileUpdate2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdateAndDelete", testFileUpdate2Name)); string testFileUpdate3Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdateAndDelete", testFileUpdate3Name)); string testFileDelete1Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdateAndDelete", testFileDelete1Name)); string testFileDelete2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdateAndDelete", testFileDelete2Name)); string testFileDelete3Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdateAndDelete", testFileDelete3Name)); testFileUpdate1Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate1Contents); testFileUpdate2Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate2Contents); testFileUpdate3Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate3Contents); testFileDelete1Path.ShouldBeAFile(this.fileSystem).WithContents(testFileDelete1Contents); testFileDelete2Path.ShouldBeAFile(this.fileSystem).WithContents(testFileDelete2Contents); testFileDelete3Path.ShouldBeAFile(this.fileSystem).WithContents(testFileDelete3Contents); using (SafeFileHandle testFileUpdate1Handle = this.CreateFile(testFileUpdate1Path, FileShare.Read)) using (SafeFileHandle testFileUpdate2Handle = this.CreateFile(testFileUpdate2Path, FileShare.Read)) using (SafeFileHandle testFileUpdate3Handle = this.CreateFile(testFileUpdate3Path, FileShare.Read)) using (SafeFileHandle testFileDelete1Handle = this.CreateFile(testFileDelete1Path, FileShare.Read)) using (SafeFileHandle testFileDelete2Handle = this.CreateFile(testFileDelete2Path, FileShare.Read)) using (SafeFileHandle testFileDelete3Handle = this.CreateFile(testFileDelete3Path, FileShare.Read)) { testFileUpdate1Handle.IsInvalid.ShouldEqual(false); testFileUpdate2Handle.IsInvalid.ShouldEqual(false); testFileUpdate3Handle.IsInvalid.ShouldEqual(false); testFileDelete1Handle.IsInvalid.ShouldEqual(false); testFileDelete2Handle.IsInvalid.ShouldEqual(false); testFileDelete3Handle.IsInvalid.ShouldEqual(false); ProcessResult checkoutResult = GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "checkout " + OldCommitId); checkoutResult.Errors.ShouldContain( "HEAD is now at " + OldCommitId, "GSD was unable to delete the following files. To recover, close all handles to the files and run these commands:", "git clean -f " + TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileDelete1Name, "git clean -f " + TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileDelete2Name, "git clean -f " + TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileDelete3Name, "GSD was unable to update the following files. To recover, close all handles to the files and run these commands:", "git checkout -- " + TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate1Name, "git checkout -- " + TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate2Name, "git checkout -- " + TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate3Name); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "HEAD detached at " + OldCommitId, "modified: Test_EPF_UpdatePlaceholderTests/LockToPreventUpdateAndDelete/test.txt", "modified: Test_EPF_UpdatePlaceholderTests/LockToPreventUpdateAndDelete/test2.txt", "modified: Test_EPF_UpdatePlaceholderTests/LockToPreventUpdateAndDelete/test3.txt", "Untracked files:\n (use \"git add <file>...\" to include in what will be committed)\n\n\tTest_EPF_UpdatePlaceholderTests/LockToPreventUpdateAndDelete/test_delete.txt\n\tTest_EPF_UpdatePlaceholderTests/LockToPreventUpdateAndDelete/test_delete2.txt\n\tTest_EPF_UpdatePlaceholderTests/LockToPreventUpdateAndDelete/test_delete3.txt", "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n"); } this.GitCheckoutToDiscardChanges(TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate1Name); this.GitCheckoutToDiscardChanges(TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate2Name); this.GitCheckoutToDiscardChanges(TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate3Name); this.GitCleanFile(TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileDelete1Name); this.GitCleanFile(TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileDelete2Name); this.GitCleanFile(TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileDelete3Name); this.GitStatusShouldBeClean(OldCommitId); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate1Name); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate2Name); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate3Name); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileDelete1Name); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileDelete2Name); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileDelete3Name); testFileUpdate1Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate1OldContents); testFileUpdate2Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate2OldContents); testFileUpdate3Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate3OldContents); testFileDelete1Path.ShouldNotExistOnDisk(this.fileSystem); testFileDelete2Path.ShouldNotExistOnDisk(this.fileSystem); testFileDelete3Path.ShouldNotExistOnDisk(this.fileSystem); this.GitCheckoutCommitId(NewFilesAndChangesCommitId); this.GitStatusShouldBeClean(NewFilesAndChangesCommitId); testFileUpdate1Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate1Contents); testFileUpdate2Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate2Contents); testFileUpdate3Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate3Contents); testFileDelete1Path.ShouldBeAFile(this.fileSystem).WithContents(testFileDelete1Contents); testFileDelete2Path.ShouldBeAFile(this.fileSystem).WithContents(testFileDelete2Contents); testFileDelete3Path.ShouldBeAFile(this.fileSystem).WithContents(testFileDelete3Contents); }
public void LockToPreventUpdate_MultipleFiles() { string testFile2Contents = "Commit2LockToPreventUpdate2 \r\n"; string testFile3Contents = "Commit2LockToPreventUpdate3 \r\n"; string testFile4Contents = "Commit2LockToPreventUpdate4 \r\n"; string testFile2OldContents = "TestFileLockToPreventUpdate2 \r\n"; string testFile3OldContents = "TestFileLockToPreventUpdate3 \r\n"; string testFile4OldContents = "TestFileLockToPreventUpdate4 \r\n"; string testFile2Name = "test2.txt"; string testFile3Name = "test3.txt"; string testFile4Name = "test4.txt"; string testFile2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdate", testFile2Name)); string testFile3Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdate", testFile3Name)); string testFile4Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdate", testFile4Name)); testFile2Path.ShouldBeAFile(this.fileSystem).WithContents(testFile2Contents); testFile3Path.ShouldBeAFile(this.fileSystem).WithContents(testFile3Contents); testFile4Path.ShouldBeAFile(this.fileSystem).WithContents(testFile4Contents); using (SafeFileHandle testFile2Handle = this.CreateFile(testFile2Path, FileShare.Read)) using (SafeFileHandle testFile3Handle = this.CreateFile(testFile3Path, FileShare.Read)) using (SafeFileHandle testFile4Handle = this.CreateFile(testFile4Path, FileShare.Read)) { testFile2Handle.IsInvalid.ShouldEqual(false); testFile3Handle.IsInvalid.ShouldEqual(false); testFile4Handle.IsInvalid.ShouldEqual(false); ProcessResult result = this.InvokeGitAgainstGSDRepo("checkout " + OldCommitId); result.Errors.ShouldContain( "GSD was unable to update the following files. To recover, close all handles to the files and run these commands:", "git checkout -- " + TestParentFolderName + "/LockToPreventUpdate/" + testFile2Name, "git checkout -- " + TestParentFolderName + "/LockToPreventUpdate/" + testFile3Name, "git checkout -- " + TestParentFolderName + "/LockToPreventUpdate/" + testFile4Name); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "HEAD detached at " + OldCommitId, "Changes not staged for commit:", TestParentFolderName + "/LockToPreventUpdate/" + testFile2Name, TestParentFolderName + "/LockToPreventUpdate/" + testFile3Name, TestParentFolderName + "/LockToPreventUpdate/" + testFile4Name); } this.GitCheckoutToDiscardChanges(TestParentFolderName + "/LockToPreventUpdate/" + testFile2Name); this.GitCheckoutToDiscardChanges(TestParentFolderName + "/LockToPreventUpdate/" + testFile3Name); this.GitCheckoutToDiscardChanges(TestParentFolderName + "/LockToPreventUpdate/" + testFile4Name); this.GitStatusShouldBeClean(OldCommitId); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdate/" + testFile2Name); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdate/" + testFile3Name); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdate/" + testFile4Name); testFile2Path.ShouldBeAFile(this.fileSystem).WithContents(testFile2OldContents); testFile3Path.ShouldBeAFile(this.fileSystem).WithContents(testFile3OldContents); testFile4Path.ShouldBeAFile(this.fileSystem).WithContents(testFile4OldContents); this.GitCheckoutCommitId(NewFilesAndChangesCommitId); this.GitStatusShouldBeClean(NewFilesAndChangesCommitId); testFile2Path.ShouldBeAFile(this.fileSystem).WithContents(testFile2Contents); testFile3Path.ShouldBeAFile(this.fileSystem).WithContents(testFile3Contents); testFile4Path.ShouldBeAFile(this.fileSystem).WithContents(testFile4Contents); }
private void GitCheckoutToDiscardChanges(string gitPath) { GitHelpers.CheckGitCommandAgainstGSDRepo(this.Enlistment.RepoRoot, "checkout -- " + gitPath); }
public void LockMoreThanMaxReportedFileNames() { string updateFilesFolder = "FilesToUpdate"; string deleteFilesFolder = "FilesToDelete"; for (int i = 1; i <= 51; ++i) { this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "MaxFileListCount", updateFilesFolder, i.ToString() + ".txt")).ShouldBeAFile(this.fileSystem); this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "MaxFileListCount", deleteFilesFolder, i.ToString() + ".txt")).ShouldBeAFile(this.fileSystem); } List <SafeFileHandle> openHandles = new List <SafeFileHandle>(); try { for (int i = 1; i <= 51; ++i) { SafeFileHandle handle = this.CreateFile( this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "MaxFileListCount", updateFilesFolder, i.ToString() + ".txt")), FileShare.Read); openHandles.Add(handle); handle.IsInvalid.ShouldEqual(false); handle = this.CreateFile( this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "MaxFileListCount", deleteFilesFolder, i.ToString() + ".txt")), FileShare.Read); openHandles.Add(handle); handle.IsInvalid.ShouldEqual(false); } ProcessResult result = this.InvokeGitAgainstGSDRepo("checkout " + OldCommitId); result.Errors.ShouldContain( "GSD failed to update 102 files, run 'git status' to check the status of files in the repo"); List <string> expectedOutputStrings = new List <string>() { "HEAD detached at " + OldCommitId, "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n" }; for (int expectedFilePrefix = 1; expectedFilePrefix <= 51; ++expectedFilePrefix) { expectedOutputStrings.Add("modified: Test_EPF_UpdatePlaceholderTests/MaxFileListCount/" + updateFilesFolder + "/" + expectedFilePrefix.ToString() + ".txt"); expectedOutputStrings.Add("Test_EPF_UpdatePlaceholderTests/MaxFileListCount/" + deleteFilesFolder + "/" + expectedFilePrefix.ToString() + ".txt"); } GitHelpers.CheckGitCommandAgainstGSDRepo(this.Enlistment.RepoRoot, "status -u", expectedOutputStrings.ToArray()); } finally { foreach (SafeFileHandle handle in openHandles) { handle.Dispose(); } } for (int i = 1; i <= 51; ++i) { this.GitCheckoutToDiscardChanges(TestParentFolderName + "/MaxFileListCount/" + updateFilesFolder + "/" + i.ToString() + ".txt"); this.GitCleanFile(TestParentFolderName + "/MaxFileListCount/" + deleteFilesFolder + "/" + i.ToString() + ".txt"); } this.GitStatusShouldBeClean(OldCommitId); this.GitCheckoutCommitId(NewFilesAndChangesCommitId); this.GitStatusShouldBeClean(NewFilesAndChangesCommitId); }