Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure dependency order for Deploy artifacts #11265

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Umbraco.Core/Udi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel;
using System.Linq;

Expand Down Expand Up @@ -44,7 +44,7 @@ protected Udi(Uri uriValue)

public int CompareTo(Udi other)
{
return string.Compare(UriValue.ToString(), other.UriValue.ToString(), StringComparison.InvariantCultureIgnoreCase);
return string.Compare(UriValue.ToString(), other.UriValue.ToString(), StringComparison.OrdinalIgnoreCase);
}

public override string ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Cms.Core;
Expand All @@ -29,6 +30,33 @@ public void CanSerialize()
Assert.AreEqual(expected, serialized);
}

[Test]
public void Dependencies_Are_Correctly_Ordered()
{
// This test was introduced following: https://github.com/umbraco/Umbraco.Deploy.Issues/issues/72 to verify
// that consistent ordering rules are used across platforms.
var udi = new GuidUdi("test", Guid.Parse("3382d5433b5749d08919bc9961422a1f"));
var artifact = new TestArtifact(udi, new List<ArtifactDependency>())
{
Name = "Test Name",
Alias = "testAlias",
};

var dependencies = new ArtifactDependencyCollection();

var dependencyUdi1 = new GuidUdi("template", Guid.Parse("d4651496fad24c1290a53ea4d55d945b"));
dependencies.Add(new ArtifactDependency(dependencyUdi1, true, ArtifactDependencyMode.Exist));

var dependencyUdi2 = new StringUdi(Constants.UdiEntityType.TemplateFile, "TestPage.cshtml");
dependencies.Add(new ArtifactDependency(dependencyUdi2, true, ArtifactDependencyMode.Exist));

artifact.Dependencies = dependencies;

Assert.AreEqual(
"umb://template-file/TestPage.cshtml,umb://template/d4651496fad24c1290a53ea4d55d945b",
string.Join(",", artifact.Dependencies.Select(x => x.Udi.ToString())));
}

private class TestArtifact : ArtifactBase<GuidUdi>
{
public TestArtifact(GuidUdi udi, IEnumerable<ArtifactDependency> dependencies = null) : base(udi, dependencies)
Expand Down