コード例 #1
0
        public void ValidateVersions()
        {
            List <VersionIdentifierTestAsset> testAssets = GetTestAssets();

            foreach (VersionIdentifierTestAsset testAsset in testAssets)
            {
                // First check whether the original version number can be identified
                string expectedVersion = testAsset.ExpectedVersion;
                string actualVersion   = VersionIdentifier.GetVersion(testAsset.Name);
                Assert.True(expectedVersion == actualVersion, $"Line {testAsset.Line} has incorrect computed version {actualVersion}");
                // Then check that all versions can be removed from the path of any blob asset
                string expectedNameWithoutVersions = testAsset.NameWithoutVersions;
                string actualNameWithoutVersions   = VersionIdentifier.RemoveVersions(testAsset.Name);
                Assert.True(expectedNameWithoutVersions == actualNameWithoutVersions, $"Line {testAsset.Line} has incorrect asset name without versions {actualNameWithoutVersions}");
            }
        }
コード例 #2
0
 public void ValidateSimpleVersions(string assetName, string version)
 {
     Assert.Equal(version, VersionIdentifier.GetVersion(assetName));
 }
コード例 #3
0
    public override bool Run(string[] args)
    {
        Console.WriteLine("");
        Console.WriteLine("Identifying version by checking NuGet feed and git origin repository...");
        Console.WriteLine("");

        var packageName = ProjectName;

        if (!CurrentNode.Properties.ContainsKey("NuGetFeedPath"))
        {
            throw new Exception("*.node file doesn't contain 'NuGetFeedPath' property.");
        }

        var sourcePath = CurrentNode.Properties["NuGetFeedPath"];

        Console.WriteLine("Feed source path:");
        Console.WriteLine(sourcePath);
        Console.WriteLine("");

        var commit = Arguments.ContainsAny("c", "commit");

        var status = "";

        if (CurrentNode.Properties.ContainsKey("Status"))
        {
            status = CurrentNode.Properties["Status"];
        }

        var branch = "";

        if (CurrentNode.Properties.ContainsKey("Branch"))
        {
            branch = CurrentNode.Properties["Branch"];
        }

        var identifier = new VersionIdentifier(branch, status, sourcePath, packageName);


        var force = Arguments.ContainsAny("f", "force");

        Console.WriteLine("Status: " + (!String.IsNullOrEmpty(status) ? status : "[Not specified]"));
        Console.WriteLine("");

        var currentVersionString = "0.0.0.0";

        if (CurrentNode.Properties.ContainsKey("Version"))
        {
            currentVersionString = CurrentNode.Properties["Version"];
        }

        if (!String.IsNullOrEmpty(status))
        {
            currentVersionString += "-" + status;
        }

        var currentVersion = new SemanticVersion(currentVersionString);

        var publishedVersion = identifier.GetVersion();

        Console.WriteLine("");
        Console.WriteLine("Current local version: " + currentVersion);
        Console.WriteLine("Latest found version: " + publishedVersion);
        Console.WriteLine("");

        bool changedVersion = false;

        if (publishedVersion != currentVersion)
        {
            if (force ||
                publishedVersion > currentVersion)
            {
                if (force)
                {
                    Console.WriteLine("Current local version is newer. Overwriting anyway.");
                }
                else
                {
                    Console.WriteLine("Latest found version is newer.");
                }

                Console.WriteLine("Using latest found version.");

                ExecuteScript("SetVersion", publishedVersion.Version.ToString());

                changedVersion = true;
            }
            else
            {
                Console.WriteLine("Current local version is newer. Keeping.");
            }
        }
        else
        {
            Console.WriteLine("Current version already matches the published version. Nothing needs to be done.");
        }

        Console.WriteLine("");

        RefreshCurrentNode();

        if (commit && changedVersion)
        {
            ExecuteScript("CommitVersion");
        }

        return(!IsError);
    }
コード例 #4
0
 public void ValidateSimpleVersions(string assetName, string version)
 {
     VersionIdentifier.GetVersion(assetName).Should().Be(version);
 }
コード例 #5
0
 internal override string GetVersion(string assetName)
 {
     return(VersionIdentifier.GetVersion(assetName));
 }