public void ShouldExitGracefullyIfNoGitInitialized() { var workingDirectory = TempDir.Create(); Should.Throw <CommandLineExitException>(() => WorkingCopy.Discover(workingDirectory)); _testPlatformAbstractions.Messages[0].ShouldBe($"Directory {workingDirectory} or any parent directory do not contain a git working copy"); Cleanup.DeleteDirectory(workingDirectory); }
public void ShouldExitIfWorkingCopyContainsNoProjects() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); var workingCopy = WorkingCopy.Discover(workingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages[0].ShouldBe($"Could not find any projects files in {workingDirectory} that have a <Version> defined in their csproj file."); Cleanup.DeleteDirectory(workingDirectory); }
public void ShouldExitIfWorkingCopyIsDirty() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); TempCsProject.Create(workingDirectory); var workingCopy = WorkingCopy.Discover(workingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages.ShouldHaveSingleItem(); _testPlatformAbstractions.Messages[0].ShouldBe($"Repository {workingDirectory} is dirty. Please commit your changes."); Cleanup.DeleteDirectory(workingDirectory); }
public void ShouldExitIfProjectsUseInconsistentNaming() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); TempCsProject.Create(Path.Join(workingDirectory, "project1"), "1.1.0"); TempCsProject.Create(Path.Join(workingDirectory, "project2"), "2.0.0"); CommitAll(tempRepository); var workingCopy = WorkingCopy.Discover(workingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages[0].ShouldBe($"Some projects in {workingDirectory} have an inconsistent <Version> defined in their csproj file. Please update all versions to be consistent or remove the <Version> elements from projects that should not be versioned"); Cleanup.DeleteDirectory(workingDirectory); }
public void ShouldIgnoreInsignificantCommits() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); TempCsProject.Create(workingDirectory); var workingFilePath = Path.Join(workingDirectory, "hello.txt"); // Create and commit a test file File.WriteAllText(workingFilePath, "First line of text"); CommitAll(tempRepository); // Run versionize var workingCopy = WorkingCopy.Discover(workingDirectory); workingCopy.Versionize(); // Add insignificant change File.AppendAllText(workingFilePath, "This is another line of text"); CommitAll(tempRepository, "chore: Added line of text"); // Get last commit var lastCommit = tempRepository.Head.Tip; // Run versionize, ignoring insignificant commits try { workingCopy.Versionize(ignoreInsignificant: true); throw new InvalidOperationException("Expected to throw in Versionize call"); } catch (CommandLineExitException ex) { ex.ExitCode.ShouldBe(0); } lastCommit.ShouldBe(tempRepository.Head.Tip); // Cleanup Cleanup.DeleteDirectory(workingDirectory); }
public void Dispose() { Cleanup.DeleteDirectory(_testDirectory); }
public void Dispose() { Repository.Dispose(); Cleanup.DeleteDirectory(WorkingDirectory); }