public void ShouldSelectAnnotatedTags() { TempCsProject.Create(Path.Join(_testSetup.WorkingDirectory, "project1"), "2.0.0"); var commit = CommitAll(_testSetup.Repository); _testSetup.Repository.Tags.Add($"v2.0.0", commit, GetAuthorSignature(), "Some annotation message without a version included"); var versionTag = _testSetup.Repository.SelectVersionTag(new System.Version(2, 0, 0)); versionTag.ToString().ShouldBe("refs/tags/v2.0.0"); }
public void ShouldDiscoverAllProjects() { var tempDir = TempDir.Create(); TempCsProject.Create(Path.Join(tempDir, "project1")); TempCsProject.Create(Path.Join(tempDir, "project2")); var projects = Projects.Discover(tempDir); projects.GetProjectFiles().Count().ShouldBe(2); }
public void ShouldSelectLightweight() { TempCsProject.Create(Path.Join(_testSetup.WorkingDirectory, "project1"), "2.0.0"); var commit = CommitAll(_testSetup.Repository); _testSetup.Repository.Tags.Add($"v2.0.0", commit); var versionTag = _testSetup.Repository.SelectVersionTag(new System.Version(2, 0, 0)); versionTag.ToString().ShouldBe("refs/tags/v2.0.0"); }
public void ShouldDetectConsistentVersions() { var tempDir = TempDir.Create(); TempCsProject.Create(Path.Join(tempDir, "project1")); TempCsProject.Create(Path.Join(tempDir, "project2")); var projects = Projects.Discover(tempDir); projects.HasInconsistentVersioning().ShouldBeFalse(); }
public void ShouldExitIfWorkingCopyIsDirty() { TempCsProject.Create(_testSetup.WorkingDirectory); var workingCopy = WorkingCopy.Discover(_testSetup.WorkingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages.ShouldHaveSingleItem(); _testPlatformAbstractions.Messages[0].ShouldBe($"Repository {_testSetup.WorkingDirectory} is dirty. Please commit your changes."); }
public void ShouldExitIfProjectsUseInconsistentNaming() { TempCsProject.Create(Path.Join(_testSetup.WorkingDirectory, "project1"), "1.1.0"); TempCsProject.Create(Path.Join(_testSetup.WorkingDirectory, "project2"), "2.0.0"); CommitAll(_testSetup.Repository); var workingCopy = WorkingCopy.Discover(_testSetup.WorkingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages[0].ShouldBe($"Some projects in {_testSetup.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"); }
public void ShouldWriteAllVersionsToProjectFiles() { var tempDir = TempDir.Create(); TempCsProject.Create(Path.Join(tempDir, "project1"), "1.1.1"); TempCsProject.Create(Path.Join(tempDir, "project2"), "1.1.1"); var projects = Projects.Discover(tempDir); projects.WriteVersion(new Version(2, 0, 0)); var updated = Projects.Discover(tempDir); updated.Version.ShouldBe(new Version("2.0.0")); }
public void ShouldPreformADryRun() { TempCsProject.Create(_testSetup.WorkingDirectory); File.WriteAllText(Path.Join(_testSetup.WorkingDirectory, "hello.txt"), "First commit"); CommitAll(_testSetup.Repository); File.WriteAllText(Path.Join(_testSetup.WorkingDirectory, "hello.txt"), "Second commit"); CommitAll(_testSetup.Repository); var workingCopy = WorkingCopy.Discover(_testSetup.WorkingDirectory); workingCopy.Versionize(dryrun: true, skipDirtyCheck: true); _testPlatformAbstractions.Messages.Count.ShouldBe(4); _testPlatformAbstractions.Messages[0].ShouldBe("Discovered 1 versionable projects"); }
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 ShouldAddSuffixToReleaseCommitMessage() { TempCsProject.Create(_testSetup.WorkingDirectory); var workingFilePath = Path.Join(_testSetup.WorkingDirectory, "hello.txt"); // Create and commit a test file File.WriteAllText(workingFilePath, "First line of text"); CommitAll(_testSetup.Repository); // Run versionize var workingCopy = WorkingCopy.Discover(_testSetup.WorkingDirectory); var suffix = "[skip ci]"; workingCopy.Versionize(releaseCommitMessageSuffix: suffix); // Get last commit var lastCommit = _testSetup.Repository.Head.Tip; lastCommit.Message.ShouldContain(suffix); }