Ejemplo n.º 1
0
        public static void ConfigureGitVersion(ICakeContext ctx, TaskConfig cfg)
        {
            // Update the GitVersion config
            GitVersionConfig gitVersion = cfg.Load <GitVersionConfig>();

            Common.Tools.GitVersion.GitVersion version = ctx.GitVersion();
            gitVersion.Version = version;

            EnvConfig env = cfg.Load <EnvConfig>();

            // Update branch name
            env.Branch = version.BranchName;

            // Update primary and full versions
            env.Version.Primary = version.MajorMinorPatch;
            env.Version.Full    = version.SemVer;

            // Update build number
            env.Version.BuildNumber = version.CommitsSinceVersionSource.HasValue
                ? version.CommitsSinceVersionSource.Value.ToString()
                : version.BuildMetaData;
        }
Ejemplo n.º 2
0
            public void Should_Tolerate_Bad_Json_Set()
            {
                // Given
                var expect = new Common.Tools.GitVersion.GitVersion
                {
                    Major                 = 0,
                    Minor                 = 1,
                    Patch                 = 1,
                    PreReleaseTag         = "PreReleaseTag",
                    PreReleaseTagWithDash = "PreReleaseTagWithDash",
                    PreReleaseLabel       = "PreReleaseLabel",
                    PreReleaseNumber      = null,
                    BuildMetaData         = "BuildMetaData",
                    BuildMetaDataPadded   = "BuildMetaDataPadded",
                    FullBuildMetaData     = "Branch.master.Sha.f2467748c78b3c8b37972ad0b30df2e15dfbf2cb",
                    MajorMinorPatch       = "0.1.1",
                    SemVer                = "0.1.1",
                    LegacySemVer          = "0.1.1",
                    LegacySemVerPadded    = "0.1.1",
                    AssemblySemVer        = "0.1.1.0",
                    AssemblySemFileVer    = "0.1.1.0",
                    FullSemVer            = "0.1.1",
                    InformationalVersion  = "0.1.1+Branch.master.Sha.f2467748c78b3c8b37972ad0b30df2e15dfbf2cb",
                    BranchName            = "master",
                    Sha                             = "f2467748c78b3c8b37972ad0b30df2e15dfbf2cb",
                    NuGetVersionV2                  = "0.1.1",
                    NuGetVersion                    = "0.1.1",
                    CommitsSinceVersionSource       = null,
                    CommitsSinceVersionSourcePadded = "0002",
                    CommitDate                      = "2017-09-13",
                }
                ;
                var fixture = new GitVersionRunnerFixture(
                    new[]
                {
                    "{",
                    "  \"Major\":0,",
                    "  \"Minor\":1,",
                    "  \"Patch\":1,",
                    "  \"PreReleaseTag\":\"PreReleaseTag\",",
                    "  \"PreReleaseTagWithDash\":\"PreReleaseTagWithDash\",",
                    "  \"PreReleaseLabel\":\"PreReleaseLabel\",",
                    "  \"PreReleaseNumber\":\"\",",
                    "  \"BuildMetaData\":\"BuildMetaData\",",
                    "  \"BuildMetaDataPadded\":\"BuildMetaDataPadded\",",
                    "  \"FullBuildMetaData\":\"Branch.master.Sha.f2467748c78b3c8b37972ad0b30df2e15dfbf2cb\",",
                    "  \"MajorMinorPatch\":\"0.1.1\",",
                    "  \"SemVer\":\"0.1.1\",",
                    "  \"LegacySemVer\":\"0.1.1\",",
                    "  \"LegacySemVerPadded\":\"0.1.1\",",
                    "  \"AssemblySemVer\":\"0.1.1.0\",",
                    "  \"AssemblySemFileVer\":\"0.1.1.0\",",
                    "  \"FullSemVer\":\"0.1.1\",",
                    "  \"InformationalVersion\":\"0.1.1+Branch.master.Sha.f2467748c78b3c8b37972ad0b30df2e15dfbf2cb\",",
                    "  \"BranchName\":\"master\",",
                    "  \"Sha\":\"f2467748c78b3c8b37972ad0b30df2e15dfbf2cb\",",
                    "  \"NuGetVersionV2\":\"0.1.1\",",
                    "  \"NuGetVersion\":\"0.1.1\",",
                    "  \"CommitsSinceVersionSource\":\"\",",
                    "  \"CommitsSinceVersionSourcePadded\":\"0002\",",
                    "  \"CommitDate\":\"2017-09-13\"",
                    "}"
                });

                fixture.Settings.OutputType = GitVersionOutput.Json;

                // When
                var result = fixture.RunGitVersion();

                // Then
                Assert.Equal(expect.Major, result.Major);
                Assert.Equal(expect.Minor, result.Minor);
                Assert.Equal(expect.Patch, result.Patch);
                Assert.Equal(expect.PreReleaseTag, result.PreReleaseTag);
                Assert.Equal(expect.PreReleaseTagWithDash, result.PreReleaseTagWithDash);
                Assert.Equal(expect.PreReleaseLabel, result.PreReleaseLabel);
                Assert.Equal(expect.PreReleaseNumber, result.PreReleaseNumber);
                Assert.Equal(expect.BuildMetaData, result.BuildMetaData);
                Assert.Equal(expect.BuildMetaDataPadded, result.BuildMetaDataPadded);
                Assert.Equal(expect.FullBuildMetaData, result.FullBuildMetaData);
                Assert.Equal(expect.MajorMinorPatch, result.MajorMinorPatch);
                Assert.Equal(expect.SemVer, result.SemVer);
                Assert.Equal(expect.LegacySemVer, result.LegacySemVer);
                Assert.Equal(expect.LegacySemVerPadded, result.LegacySemVerPadded);
                Assert.Equal(expect.AssemblySemVer, result.AssemblySemVer);
                Assert.Equal(expect.AssemblySemFileVer, result.AssemblySemFileVer);
                Assert.Equal(expect.FullSemVer, result.FullSemVer);
                Assert.Equal(expect.InformationalVersion, result.InformationalVersion);
                Assert.Equal(expect.BranchName, result.BranchName);
                Assert.Equal(expect.Sha, result.Sha);
                Assert.Equal(expect.NuGetVersionV2, result.NuGetVersionV2);
                Assert.Equal(expect.NuGetVersion, result.NuGetVersion);
                Assert.Equal(expect.CommitsSinceVersionSource, result.CommitsSinceVersionSource);
                Assert.Equal(expect.CommitsSinceVersionSourcePadded, result.CommitsSinceVersionSourcePadded);
                Assert.Equal(expect.CommitDate, result.CommitDate);
            }