Exemple #1
0
        public async Task Repository_path_can_be_passed_as_relative_path()
        {
            // ARRANGE
            using var temporaryDirectory = new TemporaryDirectory();
            var repositoryPath = temporaryDirectory.AddSubDirectory("repo");

            var git = new GitWrapper(repositoryPath, m_TestOutputHelper);
            await git.InitAsync();

            await git.ConfigAsync("user.name", "Example");

            await git.ConfigAsync("user.email", "*****@*****.**");

            var commit = await git.CommitAsync("feat: Some New feature");

            await git.TagAsync("v1.0.0", commit);

            await Task.Delay(500);

            var expectedOutputPath = Path.Combine(repositoryPath, "changelog.md");

            // ACT
            var result = await RunApplicationAsync(
                args : new[] { "--repository", "repo" },
                workingDirectory : temporaryDirectory,
                commandId : nameof(Repository_path_can_be_passed_as_relative_path)
                );

            // ASSERT
            Assert.Equal(0, result.ExitCode);
            Assert.True(File.Exists(expectedOutputPath));
        }
Exemple #2
0
        public async Task TryGetRepositoryPath_succeeds_when_starting_path_is_a_subdirectory_of_git_repository(string relativePath)
        {
            // ARRANGE
            using var temporaryDirectory = new TemporaryDirectory();
            var git = new GitWrapper(temporaryDirectory, m_TestOutputHelper);
            await git.InitAsync();

            var startingPath = temporaryDirectory.AddSubDirectory(relativePath);

            // ACT
            var success = RepositoryLocator.TryGetRepositoryPath(startingPath, out var actualRepositoryPath);

            // ASSERT
            Assert.True(success);
            Assert.Equal(temporaryDirectory, actualRepositoryPath?.TrimEnd(Path.DirectorySeparatorChar));
        }
Exemple #3
0
        public async Task When_no_repository_is_specified_the_repository_is_located_from_the_current_directory(string relativeWorkingDirectoryPath)
        {
            // ARRANGE
            using var temporaryDirectory = new TemporaryDirectory();
            var workingDirectory = temporaryDirectory.AddSubDirectory(relativeWorkingDirectoryPath);

            var git = new GitWrapper(temporaryDirectory, m_TestOutputHelper);
            await git.InitAsync();

            await git.ConfigAsync("user.name", "Example");

            await git.ConfigAsync("user.email", "*****@*****.**");

            var commit = await git.CommitAsync("feat: Some New feature");

            await git.TagAsync("v1.0.0", commit);

            await Task.Delay(500);

            var expectedOutputPath = Path.Combine(temporaryDirectory, "changelog.md");
            var expectedOutput     = String.Join(Environment.NewLine,
                                                 "# Change Log",
                                                 "",
                                                 "## 1.0.0",
                                                 "",
                                                 $"#### <a id=\"changelog-heading-{commit.Id.Id}\"></a> Some New feature",
                                                 "",
                                                 $"- Commit: `{commit.Id.AbbreviatedId}`",
                                                 "");

            // ACT
            var result = await RunApplicationAsync(
                args : new[] { "--verbose" },
                workingDirectory : workingDirectory,
                commandId : $"{nameof(When_no_repository_is_specified_the_repository_is_located_from_the_current_directory)}(\"{relativeWorkingDirectoryPath}\")"
                );

            // ASSERT
            Assert.Equal(0, result.ExitCode);
            Assert.True(File.Exists(expectedOutputPath));
            Assert.Equal(expectedOutput, File.ReadAllText(expectedOutputPath));
        }