public VersionedApplication AddVersionedApplication(string applicationIdentifier, string applicationDescription,
     SemVersion startingVersion)
 {
     var versionedApplicationState = new VersionedApplicationState("", "");
     versionedApplicationState.BuildHistory.Add(new VersionControlIdEntry("", startingVersion));
     return new VersionedApplication(versionedApplicationState);
 }
        private static void HandleMigrations()
        {
            const string productName = "Redirects";
            var currentVersion = new SemVersion(0, 0, 0);

            // get all migrations for "Statistics" already executed
            var migrations = ApplicationContext.Current.Services.MigrationEntryService.GetAll(productName);

            // get the latest migration for "Statistics" executed
            var latestMigration = migrations.OrderByDescending(x => x.Version).FirstOrDefault();

            if (latestMigration != null)
                currentVersion = latestMigration.Version;

            var targetVersion = new SemVersion(1, 0, 1);
            if (targetVersion == currentVersion)
                return;

            var migrationsRunner = new MigrationRunner(
              ApplicationContext.Current.Services.MigrationEntryService,
              ApplicationContext.Current.ProfilingLogger.Logger,
              currentVersion,
              targetVersion,
              productName);

            try
            {
                migrationsRunner.Execute(UmbracoContext.Current.Application.DatabaseContext.Database);
            }
            catch (HttpException e){}
            catch (Exception e)
            {
                LogHelper.Error<MigrationRunner>("Error running Redirects migration", e);
            }
        }
		public DataFileTypeInfoProperty(SemVersion v, string n, string t, Func<BaseDataFile, BaseDataFile> g, Action<BaseDataFile, BaseDataFile> s)
		{
			MinimalVersion = v;
			PropertyName = n;
			TypeName = t;
			Getter = g;
			Setter = s;
		}
 /// <summary>Initialises a new instance of the <see cref="ChangeVersionViewModel"/> class.</summary>
 /// <param name="version">The version that is going to be changed.</param>
 public ChangeVersionViewModel(SemVersion version)
 {
     this.Major = version.Major;
     this.Minor = version.Minor;
     this.Patch = version.Patch;
     this.Prerelease = version.Prerelease;
     this.Build = version.Build;
 }
Exemplo n.º 5
0
        void Init(string owner, string name, SemVersion version)
        {
            Github = new GitHubClient(new ProductHeaderValue(name + @"-UpdateCheck"));
            _releaseClient = Github.Release;

            RepositoryOwner = owner;
            RepostoryName = name;
            CurrentVersion = version;
        }
Exemplo n.º 6
0
        public void CreateVersionTest()
        {
            var v = new SemVersion(1, 2, 3, "a", "b");

            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(2, v.Minor);
            Assert.AreEqual(3, v.Patch);
            Assert.AreEqual("a", v.Prerelease);
            Assert.AreEqual("b", v.Build);
        }
Exemplo n.º 7
0
        public void CreateVersionTestWithNulls()
        {
            var v = new SemVersion(1, 2, 3, null, null);

            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(2, v.Minor);
            Assert.AreEqual(3, v.Patch);
            Assert.AreEqual("", v.Prerelease);
            Assert.AreEqual("", v.Build);
        }
Exemplo n.º 8
0
        public void CreateVersionTestWithSystemVersion2()
        {
            var v = new SemVersion(null);

            Assert.AreEqual(0, v.Major);
            Assert.AreEqual(0, v.Minor);
            Assert.AreEqual(0, v.Patch);
            Assert.AreEqual("", v.Build);
            Assert.AreEqual("", v.Prerelease);
        }
Exemplo n.º 9
0
        public void CreateVersionTestWithSystemVersion3()
        {
            var nonSemanticVersion = new Version(1, 2, 0, 3);
            var v = new SemVersion(nonSemanticVersion);

            Assert.AreEqual(1, v.Major);
            Assert.AreEqual(2, v.Minor);
            Assert.AreEqual(3, v.Patch);
            Assert.AreEqual("", v.Build);
            Assert.AreEqual("", v.Prerelease);
        }
Exemplo n.º 10
0
		public override void Deserialize(IDataReader reader, SemVersion archiveVersion)
		{
			try
			{
				Value = Guid.ParseExact(reader.ReadFixedLengthNonEscapedASCII(36), "D");
			}
			catch (Exception e)
			{
				throw new SAMPersistanceException(e);
			}
		}
Exemplo n.º 11
0
        public async Task<UpdateType> CheckUpdate(UpdateType locked = UpdateType.None)
        {
            var releases = await _releaseClient.GetAll(RepositoryOwner, RepostoryName);

            SemVersion lockedVersion;
            switch (locked)
            {
                case UpdateType.Major:
                    lockedVersion = new SemVersion(CurrentVersion.Major + 1);
                    LatestRelease = releases.FirstOrDefault(
                        release => !release.Prerelease &&
                        Helper.StripInitialV(release.TagName) > CurrentVersion &&
                        Helper.StripInitialV(release.TagName) < lockedVersion
                    );
                    break;
                case UpdateType.Minor:
                    lockedVersion = new SemVersion(CurrentVersion.Major, CurrentVersion.Minor + 1);
                    LatestRelease = releases.FirstOrDefault(
                        release => !release.Prerelease &&
                        Helper.StripInitialV(release.TagName) > CurrentVersion &&
                        Helper.StripInitialV(release.TagName) < lockedVersion
                    );
                    break;
                default:
                    LatestRelease = releases.FirstOrDefault(
                        release => !release.Prerelease &&
                        Helper.StripInitialV(release.TagName) > CurrentVersion
                    );
                    break;
            }

            if (LatestRelease == null) return UpdateType.None;

            var tagName = LatestRelease.TagName;
            var latestVersion = Helper.StripInitialV(tagName);

            if (latestVersion.Major != CurrentVersion.Major)
                return UpdateType.Major;
            if (latestVersion.Minor != CurrentVersion.Minor)
                return UpdateType.Minor;
            if (latestVersion.Patch != CurrentVersion.Patch)
                return UpdateType.Patch;

            return UpdateType.None;
        }
Exemplo n.º 12
0
        public void Delete(SemVersion semver)
        {
            // Create a retrieve operation that expects a customer entity.
            var retrieveOperation = TableOperation.Retrieve<ReleaseEntity>(semver.ToString(), semver.ToString());

            // Execute the operation.
            var retrievedResult = _table.Execute(retrieveOperation);

            // Assign the result to a CustomerEntity.
            var deleteEntity = (ReleaseEntity) retrievedResult.Result;

            // Create the Delete TableOperation.
            if (deleteEntity != null)
            {
                var deleteOperation = TableOperation.Delete(deleteEntity);

                // Execute the operation.
                _table.Execute(deleteOperation);
            }
        }
Exemplo n.º 13
0
        public void GreaterOrEqualOperatorTest1()
        {
            var v1 = new SemVersion(1);
            var v2 = new SemVersion(1);

            var r = v1 >= v2;
            Assert.IsTrue(r);
        }
Exemplo n.º 14
0
 public VersionData(string version, string minVersion)
 {
     Version    = SemVersion.Parse(version);
     MinVersion = SemVersion.Parse(minVersion);
 }
Exemplo n.º 15
0
        internal static SemVersion GetAppVersion()
        {
            var attribute = (AssemblyInformationalVersionAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), true).Single();

            return(SemVersion.Parse(attribute.InformationalVersion));
        }
Exemplo n.º 16
0
		public void WriteVersion(SemVersion v)
		{
			WriteSimpleInteger(v.Mayor, 5);
			WriteSimpleInteger(v.Minor, 5);
			WriteSimpleInteger(v.Patch, 5);
		}
Exemplo n.º 17
0
 public VerifyLoaderVersionAttribute(SemVersion semver, bool is_minimum)
 {
     SemVer = semver;
     IsMinimum = is_minimum;
 }
Exemplo n.º 18
0
        public void StaticEqualsTest3()
        {
            var v1 = new SemVersion(1);

            var r = SemVersion.Equals(v1, null);
            Assert.IsFalse(r);
        }
Exemplo n.º 19
0
 public void TestSerialization()
 {
     var semVer = new SemVersion(1, 2, 3, "alpha", "dev");
     SemVersion semVerSerializedDeserialized;
     using (var ms = new MemoryStream())
     {
         var bf = new BinaryFormatter();
         bf.Serialize(ms, semVer);
         ms.Position = 0;
         semVerSerializedDeserialized = (SemVersion) bf.Deserialize(ms);
     }
     Assert.AreEqual(semVer, semVerSerializedDeserialized);
 }
Exemplo n.º 20
0
        public void TryParseTest2()
        {
            SemVersion v;

            Assert.False(SemVersion.TryParse("ui-2.1-alpha", out v));
        }
Exemplo n.º 21
0
        public void TryParseTest3()
        {
            SemVersion v;

            Assert.False(SemVersion.TryParse("", out v));
        }
Exemplo n.º 22
0
 public void ParseTestStrict4()
 {
     Assert.Throws <InvalidOperationException>(() => SemVersion.Parse("1.3-alpha", true));
 }
Exemplo n.º 23
0
        public void TryParseTest1()
        {
            SemVersion v;

            Assert.True(SemVersion.TryParse("1.2.45-alpha-beta+nightly.23.43-bla", out v));
        }
Exemplo n.º 24
0
 public void ParseTest7()
 {
     Assert.Throws <ArgumentException>(() => SemVersion.Parse("ui-2.1-alpha"));
 }
Exemplo n.º 25
0
        public void CompareTestWithStrings2()
        {
            var v = new SemVersion(1, 0, 0);

            Assert.True(v < "1.1");
        }
Exemplo n.º 26
0
 private static bool DifferByBuildOnly(SemVersion v1, SemVersion v2)
 {
     return(v1.Change(build: "").Equals(v2.Change(build: "")));
 }
Exemplo n.º 27
0
        public void StaticCompareTest1()
        {
            var v1 = new SemVersion(1);
            var v2 = new SemVersion(2);

            var r = SemVersion.Compare(v1, v2);
            Assert.AreEqual(-1, r);
        }
Exemplo n.º 28
0
        public void CompareTestWithStrings3()
        {
            var v = new SemVersion(1, 2);

            Assert.True(v > "1.0.0");
        }
Exemplo n.º 29
0
        public void StaticCompareTest3()
        {
            var v1 = new SemVersion(1);

            var r = SemVersion.Compare(null, v1);
            Assert.AreEqual(-1, r);
        }
Exemplo n.º 30
0
        public void TryParseTest4()
        {
            SemVersion v;

            Assert.False(SemVersion.TryParse(null, out v));
        }
Exemplo n.º 31
0
        public void TestChangeMinor()
        {
            var v1 = new SemVersion(1, 2, 3, "alpha", "dev");
            var v2 = v1.Change(minor: 5);

            Assert.AreEqual(1, v2.Major);
            Assert.AreEqual(5, v2.Minor);
            Assert.AreEqual(3, v2.Patch);
            Assert.AreEqual("alpha", v2.Prerelease);
            Assert.AreEqual("dev", v2.Build);
        }
Exemplo n.º 32
0
        public void TryParseTest5()
        {
            SemVersion v;

            Assert.True(SemVersion.TryParse("1.2", out v, false));
        }
Exemplo n.º 33
0
        public void ToStringTest()
        {
            var version = new SemVersion(1, 2, 0, "beta", "dev-mha.120");

            Assert.AreEqual("1.2.0-beta+dev-mha.120", version.ToString());
        }
Exemplo n.º 34
0
        public void TryParseTest6()
        {
            SemVersion v;

            Assert.False(SemVersion.TryParse("1.2", out v, true));
        }
 public bool TryGetMinSemVersion(out SemVersion semVersion)
 {
     return(TryParseSemVersion(this.Min, out semVersion));
 }
Exemplo n.º 36
0
        public void ToStringTest()
        {
            var version = new SemVersion(1, 2, 0, "beta", "dev-mha.120");

            Assert.Equal("1.2.0-beta+dev-mha.120", version.ToString());
        }
Exemplo n.º 37
0
 public VerifyLoaderVersionAttribute(string version, bool is_minimum) : this(SemVersion.Parse(version), is_minimum) { }
Exemplo n.º 38
0
        public void TestStringConversion()
        {
            SemVersion v = "1.0.0";

            Assert.Equal(1, v.Major);
        }
Exemplo n.º 39
0
        public MigrationRunner(IMigrationEntryService migrationEntryService, ILogger logger, SemVersion currentVersion, SemVersion targetVersion, string productName, params IMigration[] migrations)
        {
            if (migrationEntryService == null)
            {
                throw new ArgumentNullException("migrationEntryService");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (currentVersion == null)
            {
                throw new ArgumentNullException("currentVersion");
            }
            if (targetVersion == null)
            {
                throw new ArgumentNullException("targetVersion");
            }
            Mandate.ParameterNotNullOrEmpty(productName, "productName");

            _migrationEntryService = migrationEntryService;
            _logger         = logger;
            _currentVersion = currentVersion;
            _targetVersion  = targetVersion;
            _productName    = productName;
            //ensure this is null if there aren't any
            _migrations = migrations.Length == 0 ? null : migrations;
        }
Exemplo n.º 40
0
        public void StaticEqualsTest2()
        {
            var r = SemVersion.Equals(null, null);

            Assert.True(r);
        }
Exemplo n.º 41
0
        public void GreaterOperatorTest()
        {
            var v1 = new SemVersion(1);
            var v2 = new SemVersion(2);

            var r = v1 > v2;
            Assert.IsFalse(r);
        }
Exemplo n.º 42
0
        public void StaticCompareTest4()
        {
            var r = SemVersion.Compare(null, null);

            Assert.Equal(0, r);
        }
Exemplo n.º 43
0
        public void LessOrEqualOperatorTest2()
        {
            var v1 = new SemVersion(1);
            var v2 = new SemVersion(2);

            var r = v1 <= v2;
            Assert.IsTrue(r);
        }
		public override void Serialize(IDataWriter writer, SemVersion currentVersion)
		{
			writer.WriteDouble(Value);
		}
Exemplo n.º 45
0
        public void StaticCompareTest2()
        {
            var v1 = new SemVersion(1);

            var r = SemVersion.Compare(v1, null);
            Assert.AreEqual(1, r);
        }
Exemplo n.º 46
0
        public async Task ExecuteAsync(IPluginJobContext context)
        {
            if (!CliUtils.ParseArgs(_options, context.Args))
            {
                return;
            }

            if (_isHelp)
            {
                PrintUsage();
                return;
            }

            var(status, failureMessage) = await _apiService.GetStatusAsync();

            if (status == null)
            {
                await WriteUtils.PrintErrorAsync(failureMessage);

                return;
            }

            var pluginId = string.Empty;

            if (context.Extras != null && context.Extras.Length > 0)
            {
                pluginId = context.Extras[0];
            }

            var pluginPath = string.IsNullOrEmpty(pluginId)
                ? _settingsManager.ContentRootPath
                : PathUtils.Combine(_pathManager.GetPluginPath(pluginId));

            var(plugin, errorMessage) = await PluginUtils.ValidateManifestAsync(pluginPath);

            if (plugin == null)
            {
                await WriteUtils.PrintErrorAsync(errorMessage);

                return;
            }

            if (!string.IsNullOrEmpty(_version))
            {
                SemVersion.TryParse(plugin.Version, out var pluginVersion);
                string versionChanged;

                if (_version == "major")
                {
                    versionChanged = pluginVersion.Change(pluginVersion.Major + 1).ToString();
                }
                else if (_version == "minor")
                {
                    versionChanged = pluginVersion.Change(pluginVersion.Major, pluginVersion.Minor + 1).ToString();
                }
                else if (_version == "patch")
                {
                    versionChanged = pluginVersion.Change(pluginVersion.Major, pluginVersion.Minor, pluginVersion.Patch + 1).ToString();
                }
                else if (PluginUtils.IsSemVersion(_version))
                {
                    versionChanged = _version;
                }
                else
                {
                    await WriteUtils.PrintErrorAsync($"Invalid plugin version '{_version}'");

                    return;
                }

                if (versionChanged != plugin.Version)
                {
                    await PluginUtils.UpdateVersionAsync(pluginPath, versionChanged);

                    (plugin, errorMessage) = await PluginUtils.ValidateManifestAsync(pluginPath);

                    if (plugin == null)
                    {
                        await WriteUtils.PrintErrorAsync(errorMessage);

                        return;
                    }
                }
            }

            var packageId = PluginUtils.GetPackageId(plugin.Publisher, plugin.Name, plugin.Version);
            var zipPath   = PluginPackageJob.Package(_pathManager, plugin);
            var fileSize  = FileUtils.GetFileSizeByFilePath(zipPath);

            await Console.Out.WriteLineAsync($"Packaged: {zipPath}");

            await Console.Out.WriteLineAsync($"Publishing {packageId} ({fileSize})...");

            bool success;

            (success, failureMessage) = await _apiService.PluginPublishAsync(plugin.Publisher, zipPath);

            if (success)
            {
                await WriteUtils.PrintSuccessAsync($"Published {packageId}, your plugin will live at {CloudUtils.Www.GetPluginUrl(plugin.Publisher, plugin.Name)}.");
            }
            else
            {
                await WriteUtils.PrintErrorAsync(failureMessage);
            }
        }
Exemplo n.º 47
0
        public void StaticEqualsTest1()
        {
            var v1 = new SemVersion(1, 2, 3);
            var v2 = new SemVersion(1, 2, 3);

            var r = SemVersion.Equals(v1, v2);
            Assert.IsTrue(r);
        }
Exemplo n.º 48
0
        public void Parse_V040()
        {
            var version = SemVersion.Parse("0.4.0").ToString();

            Assert.AreEqual("0.4.0", version);
        }
Exemplo n.º 49
0
        public void TestChangeBuild()
        {
            var v1 = new SemVersion(1, 2, 3, "alpha", "dev");
            var v2 = v1.Change(build: "rel");

            Assert.AreEqual(1, v2.Major);
            Assert.AreEqual(2, v2.Minor);
            Assert.AreEqual(3, v2.Patch);
            Assert.AreEqual("alpha", v2.Prerelease);
            Assert.AreEqual("rel", v2.Build);
        }
Exemplo n.º 50
0
        public void GetHashCodeTest()
        {
            var version = new SemVersion(1).GetHashCode();

            Assert.IsNotNull(version);
        }
Exemplo n.º 51
0
        public void TestChangePrerelease()
        {
            var v1 = new SemVersion(1, 2, 3, "alpha", "dev");
            var v2 = v1.Change(prerelease: "beta");

            Assert.AreEqual(1, v2.Major);
            Assert.AreEqual(2, v2.Minor);
            Assert.AreEqual(3, v2.Patch);
            Assert.AreEqual("beta", v2.Prerelease);
            Assert.AreEqual("dev", v2.Build);
        }
Exemplo n.º 52
0
        public void CtorNull()
        {
            var v = new SemVersion(1, 0, 0, null, null);

            Assert.AreEqual("1.0.0", v.ToString());
        }
Exemplo n.º 53
0
        public void TestUntypedCompareTo()
        {
            var v1 = new SemVersion(1);
            var c = v1.CompareTo((object)v1);

            Assert.AreEqual(0, c);
        }
Exemplo n.º 54
0
 public void Test()
 {
     SemVersion.Parse("test");
     // expect wrong input
 }
Exemplo n.º 55
0
        public void UnequalOperatorTest()
        {
            var v1 = new SemVersion(1);
            var v2 = new SemVersion(2);

            var r = v1 != v2;
            Assert.IsTrue(r);
        }
Exemplo n.º 56
0
        private void Run()
        {
            if (ShowVersion)
            {
                if (SemVersion.TryParse(
                        FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location).ProductVersion,
                        out var toolVersion))
                {
                    WriteLine(toolVersion);
                }
                else
                {
                    WriteLine(typeof(Program).Assembly.GetName().Version.ToString(3));
                }
                return;
            }

            var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());

            var projectFile = !string.IsNullOrWhiteSpace(ProjectFilePath)
                ? new FileInfo(ProjectFilePath)
                : currentDirectory.EnumerateFiles("*.csproj").FirstOrDefault();

            if (projectFile is null ||
                projectFile.Exists == false)
            {
                throw new CliException(1, $"Unable to find a project file in directory '{currentDirectory}'.");
            }

            var projectFileFullName = projectFile.FullName;

            var xDocument      = XDocument.Load(projectFileFullName);
            var versionElement = xDocument.Root?.Descendants("Version").FirstOrDefault();
            var currentVersion = ParseVersion(versionElement?.Value ?? "0.0.0");

            WriteLine($"Current version: {currentVersion}");

            if (Show)
            {
                return;
            }

            SemVersion version = null;

            if (!string.IsNullOrWhiteSpace(NewVersion))
            {
                version = ParseVersion(NewVersion);
            }
            else
            {
                if (Major)
                {
                    version = currentVersion.Change(
                        currentVersion.Major + 1,
                        0,
                        0,
                        "",
                        "");
                }
                else if (Minor)
                {
                    version = currentVersion.Change(
                        minor: currentVersion.Minor + 1,
                        patch: 0,
                        prerelease: "",
                        build: "");
                }
                else if (Patch)
                {
                    version = currentVersion.Change(
                        patch: currentVersion.Patch + 1,
                        prerelease: "",
                        build: "");
                }

                if (ReleaseCandidate)
                {
                    version = (version ?? currentVersion).Change(
                        prerelease: CreatePreReleaseString(
                            ReleaseCandidateString,
                            version is null ? currentVersion.Prerelease : ""),
                        build: "");
                }
                else if (Beta)
                {
                    if (version is null &&
                        currentVersion.Prerelease.StartsWith(ReleaseCandidateString,
                                                             StringComparison.OrdinalIgnoreCase))
                    {
                        throw new CliException(1,
                                               "Can't increment beta version number of a release candidate version number.");
                    }

                    version = (version ?? currentVersion).Change(
                        prerelease: CreatePreReleaseString(BetaString,
                                                           version is null ? currentVersion.Prerelease : ""),
                        build: "");
                }
                else if (Alpha)
                {
                    if (version is null &&
                        currentVersion.Prerelease.StartsWith(ReleaseCandidateString,
                                                             StringComparison.OrdinalIgnoreCase))
                    {
                        throw new CliException(1,
                                               "Can't increment alpha version number of a release candidate version number.");
                    }

                    if (version is null &&
                        currentVersion.Prerelease.StartsWith(BetaString, StringComparison.OrdinalIgnoreCase))
                    {
                        throw new CliException(1, "Can't increment alpha version number of a beta version number.");
                    }

                    version = (version ?? currentVersion).Change(
                        prerelease: CreatePreReleaseString(AlphaString,
                                                           version is null ? currentVersion.Prerelease : ""),
                        build: "");
                }
            }

            if (version is null)
            {
                var inputVersion = Prompt.GetString("New version:");
                version = ParseVersion(inputVersion);
            }
            else
            {
                WriteLine($"New version: {version}");
            }

            if (versionElement is null)
            {
                var propertyGroupElement = xDocument.Root?.Descendants("PropertyGroup").FirstOrDefault();
                if (propertyGroupElement is null)
                {
                    propertyGroupElement = new XElement("PropertyGroup");
                    xDocument.Root?.Add(propertyGroupElement);
                }

                propertyGroupElement.Add(new XElement("Version", version));
            }
            else
            {
                versionElement.Value = version.ToString();
            }

            File.WriteAllText(projectFileFullName, xDocument.ToString());

            if (!NoGit)
            {
                if (string.IsNullOrWhiteSpace(ProjectFilePath))
                {
                    try
                    {
                        var tag     = $"{GitVersionPrefix}{version}";
                        var message = !string.IsNullOrWhiteSpace(CommitMessage)
                            ? CommitMessage
                            : tag;

                        Process.Start(new ProcessStartInfo("git", $"commit -am \"{message}\"")
                        {
                            RedirectStandardError  = true,
                            RedirectStandardOutput = true,
                        })?.WaitForExit();

                        if (!NoGitTag)
                        {
                            // Hack to make sure the wrong commit is tagged
                            Thread.Sleep(200);
                            Process.Start(new ProcessStartInfo("git", $"tag {tag}")
                            {
                                RedirectStandardError  = true,
                                RedirectStandardOutput = true,
                            })?.WaitForExit();
                        }
                    }
                    catch
                    {
                        /* Ignored */
                    }
                }
                else
                {
                    WriteLine(
                        "Not running git integration when project file has been specified, to prevent running git in wrong directory.");
                }
            }

            WriteLine($"Successfully set version to {version}");
        }
Exemplo n.º 57
0
 public void CompareTestWithStrings1()
 {
     Assert.True(SemVersion.Equals("1.0.0", "1"));
 }
Exemplo n.º 58
0
 /// <summary>
 /// Gets the initial state corresponding to a version.
 /// </summary>
 private static string GetInitState(SemVersion version)
 => InitPrefix + version + InitSuffix;
		public override void Deserialize(IDataReader reader, SemVersion archiveVersion)
		{
			Value = reader.ReadDouble();
		}
Exemplo n.º 60
0
        public void CIBuildVersion_LastReleaseBased_are_correctely_ordered(string tag)
        {
            ReleaseTagFormat formatV2 = ReleaseTagFormat.NugetPackageV2;

            var t     = ReleaseTagVersion.TryParse(tag);
            var v     = SemVersion.Parse(t.ToString(ReleaseTagFormat.SemVer), true);
            var tNext = new ReleaseTagVersion(t.OrderedVersion + 1);
            var vNext = SemVersion.Parse(tNext.ToString(ReleaseTagFormat.SemVer), true);
            var tPrev = new ReleaseTagVersion(t.OrderedVersion - 1);
            var vPrev = SemVersion.Parse(tPrev.ToString(ReleaseTagFormat.SemVer), true);

            Assert.That(vPrev < v, "{0} < {1}", vPrev, v);
            Assert.That(v < vNext, "{0} < {1}", v, vNext);

            var sNuGet     = t.ToString(formatV2);
            var sNuGetPrev = tPrev.ToString(formatV2);
            var sNuGetNext = tNext.ToString(formatV2);

            Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetPrev, sNuGet) < 0, "{0} < {1}", sNuGetPrev, sNuGet);
            Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGet, sNuGetNext) < 0, "{0} < {1}", sNuGet, sNuGetNext);


            CIBuildDescriptor ci = new CIBuildDescriptor {
                BranchName = "dev", BuildIndex = 1
            };

            string     sCI = t.ToString(ReleaseTagFormat.SemVer, ci);
            SemVersion vCi = SemVersion.Parse(sCI, true);

            Assert.That(v < vCi, "{0} < {1}", v, vCi);
            Assert.That(vCi < vNext, "{0} < {1}", vCi, vNext);

            var sNuGetCI = t.ToString(formatV2, ci);

            Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGet, sNuGetCI) < 0, "{0} < {1}", sNuGet, sNuGetCI);
            Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCI, sNuGetNext) < 0, "{0} < {1}", sNuGetCI, sNuGetNext);

            string     sCiNext = tNext.ToString(ReleaseTagFormat.SemVer, ci);
            SemVersion vCiNext = SemVersion.Parse(sCiNext, true);

            Assert.That(vCiNext > vCi, "{0} > {1}", vCiNext, vCi);
            Assert.That(vCiNext > vNext, "{0} > {1}", vCiNext, vNext);

            var sNuGetCINext = tNext.ToString(formatV2, ci);

            Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCINext, sNuGetCI) > 0, "{0} > {1}", sNuGetCINext, sNuGetCI);
            Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCINext, sNuGetNext) > 0, "{0} > {1}", sNuGetCINext, sNuGetNext);

            string     sCiPrev = tPrev.ToString(ReleaseTagFormat.SemVer, ci);
            SemVersion vCiPrev = SemVersion.Parse(sCiPrev, true);

            Assert.That(vCiPrev > vPrev, "{0} > {1}", vCiPrev, vPrev);
            Assert.That(vCiPrev < v, "{0} < {1}", vCiPrev, v);
            Assert.That(vCiPrev < vCiNext, "{0} < {1}", vCiPrev, vCiNext);

            var sNuGetCIPrev = tPrev.ToString(formatV2, ci);

            Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCIPrev, sNuGetPrev) > 0, "{0} > {1}", sNuGetCIPrev, sNuGetPrev);
            Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCIPrev, sNuGet) < 0, "{0} < {1}", sNuGetCIPrev, sNuGet);
            Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCIPrev, sNuGetCINext) < 0, "{0} < {1}", sNuGetCIPrev, sNuGetCINext);
        }