public void BeingOnBuildServerWithOutputJsonAndOutputFileDoesNotFail(string outputFile, string fileName)
        {
            using var fixture = new RemoteRepositoryFixture();
            fixture.Repository.MakeATaggedCommit("1.2.3");
            fixture.Repository.MakeACommit();

            var env = new KeyValuePair <string, string>(TeamCity.EnvironmentVariableName, "8.0.0");

            var result = GitVersionHelper.ExecuteIn(fixture.LocalRepositoryFixture.RepositoryPath, arguments: $" /output json /output buildserver /output file /outputfile {outputFile}", environments: env);

            result.ExitCode.ShouldBe(0);
            const string version = "0.1.0+4";

            result.Output.ShouldContain($"##teamcity[buildNumber '{version}']");
            result.OutputVariables.ShouldNotBeNull();
            result.OutputVariables.FullSemVer.ShouldBeEquivalentTo(version);

            var filePath = Path.Combine(fixture.LocalRepositoryFixture.RepositoryPath, fileName);
            var json     = File.ReadAllText(filePath);

            var outputVariables = VersionVariables.FromJson(json);

            outputVariables.ShouldNotBeNull();
            outputVariables.FullSemVer.ShouldBeEquivalentTo(version);
        }
        public void WorkingDirectoryWithoutGitFolderFailsWithInformativeMessage()
        {
            var result = GitVersionHelper.ExecuteIn(System.Environment.SystemDirectory, arguments: null, logToFile: false);

            result.ExitCode.ShouldNotBe(0);
            result.Output.ShouldContain("Cannot find the .git directory");
        }
        public void InvalidArgumentsExitCodeShouldNotBeZero()
        {
            using var fixture = new EmptyRepositoryFixture();
            var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " /invalid-argument");

            result.ExitCode.ShouldNotBe(0);
            result.Output.ShouldContain("Could not parse command line parameter '/invalid-argument'");
        }
        public void WorkingDirectoryWithoutCommitsFailsWithInformativeMessage()
        {
            using var fixture = new EmptyRepositoryFixture();

            var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: null, logToFile: false);

            result.ExitCode.ShouldNotBe(0);
            result.Output.ShouldContain("No commits found on the current branch.");
        }
Ejemplo n.º 5
0
        public void WixVersionFileCreationTest()
        {
            using var fixture = new EmptyRepositoryFixture();
            fixture.MakeATaggedCommit("1.2.3");
            fixture.MakeACommit();

            GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " /updatewixversionfile");
            Assert.IsTrue(File.Exists(Path.Combine(fixture.RepositoryPath, wixVersionFileName)));
        }
        public void CheckBuildServerVerbosityConsole(string verbosityArg, string expectedOutput)
        {
            using var fixture = new EmptyRepositoryFixture();
            fixture.MakeATaggedCommit("1.2.3");
            fixture.MakeACommit();

            var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: $@" {verbosityArg} -output buildserver /l ""/tmp/path""", logToFile: false);

            result.ExitCode.ShouldBe(0);
            result.Output.ShouldContain(expectedOutput);
        }
        public void LogPathContainsForwardSlash()
        {
            using var fixture = new EmptyRepositoryFixture();
            fixture.MakeATaggedCommit("1.2.3");
            fixture.MakeACommit();

            var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: @" /l ""/tmp/path""", logToFile: false);

            result.ExitCode.ShouldBe(0);
            result.Output.ShouldContain(@"""MajorMinorPatch"": ""1.2.4""");
        }
        public void BeingOnBuildServerDoesntOverrideOutputJson()
        {
            using var fixture = new RemoteRepositoryFixture();
            fixture.Repository.MakeATaggedCommit("1.2.3");
            fixture.Repository.MakeACommit();

            var env = new KeyValuePair <string, string>(TeamCity.EnvironmentVariableName, "8.0.0");

            var result = GitVersionHelper.ExecuteIn(fixture.LocalRepositoryFixture.RepositoryPath, arguments: " /output json", environments: env);

            result.ExitCode.ShouldBe(0);
            result.Output.ShouldStartWith("{");
            result.Output.TrimEnd().ShouldEndWith("}");
        }
Ejemplo n.º 9
0
        public void WixVersionFileVarCountTest()
        {
            //Make sure we have captured all the version variables by count in the Wix version file
            using var fixture = new EmptyRepositoryFixture();
            fixture.MakeATaggedCommit("1.2.3");
            fixture.MakeACommit();

            GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: null);

            GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " /updatewixversionfile");

            var gitVersionVarsInWix = GetGitVersionVarsInWixFile(Path.Combine(fixture.RepositoryPath, wixVersionFileName));
            var gitVersionVars      = VersionVariables.AvailableVariables;

            Assert.AreEqual(gitVersionVars.Count(), gitVersionVarsInWix.Count);
        }
Ejemplo n.º 10
0
        public void WixVersionFileContentTest()
        {
            using var fixture = new EmptyRepositoryFixture();
            fixture.MakeATaggedCommit("1.2.3");
            fixture.MakeACommit();

            var gitVersionExecutionResults = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: null);
            var vars = gitVersionExecutionResults.OutputVariables;

            GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " /updatewixversionfile");

            var gitVersionVarsInWix = GetGitVersionVarsInWixFile(Path.Combine(fixture.RepositoryPath, wixVersionFileName));
            var gitVersionVars      = VersionVariables.AvailableVariables;

            foreach (var variable in gitVersionVars)
            {
                vars.TryGetValue(variable, out var value);
                //Make sure the variable is present in the Wix file
                Assert.IsTrue(gitVersionVarsInWix.ContainsKey(variable));
                //Make sure the values are equal
                Assert.AreEqual(value, gitVersionVarsInWix[variable]);
            }
        }