Skip to content
Permalink
Browse files

Merge #2430 Ignore conflicts between versions of same mod

  • Loading branch information...
politas committed Apr 27, 2018
2 parents 12a8a1c + 9472385 commit 449711484d595d9c06d607b3437350dce3d22b0f
Showing with 46 additions and 17 deletions.
  1. +5 −0 CHANGELOG.md
  2. +5 −9 Core/Relationships/SanityChecker.cs
  3. +36 −8 Tests/Core/Relationships/SanityChecker.cs
@@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## v1.25.2

### Bugfixes
- [core] Ignore conflicts between versions of same mod (#2430 by: HebaruSan; reviewed: politas)

## v1.25.1

### Features
@@ -132,18 +132,15 @@ public static class SanityChecker
IDictionary<string, UnmanagedModuleVersion> dlc
)
{
modules = modules?.AsCollection();

var confl = new List<KeyValuePair<CkanModule, RelationshipDescriptor>>();

if (modules != null)
{
foreach (var m in modules.Where(m => m.conflicts != null))
foreach (CkanModule m in modules.Where(m => m.conflicts != null))
{
// Remove self from the list, so we're only comparing to OTHER modules
var others = modules.Where(other => !ReferenceEquals(other, m)).AsCollection();

foreach (var dep in m.conflicts)
// Remove self from the list, so we're only comparing to OTHER modules.
// Also remove other versions of self, to avoid conflicts during upgrades.
var others = modules.Where(other => other.identifier != m.identifier);
foreach (RelationshipDescriptor dep in m.conflicts)
{
if (dep.MatchesAny(others, dlls, dlc))
{
@@ -152,7 +149,6 @@ public static class SanityChecker
}
}
}

return confl;
}

@@ -175,8 +175,8 @@ public void IsConsistent_MismatchedDependencyVersion_Inconsistent()
""version"": ""1.0.0"",
""download"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag/download/1.01"",
""depends"": [ {
""name"": ""dependency"",
""version"": ""1.2.3""
""name"": ""dependency"",
""version"": ""1.2.3""
} ]
}"),
CkanModule.FromJson(@"{
@@ -201,8 +201,8 @@ public void IsConsistent_MatchedDependencyVersion_Consistent()
""version"": ""1.0.0"",
""download"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag/download/1.01"",
""depends"": [ {
""name"": ""dependency"",
""version"": ""1.2.3""
""name"": ""dependency"",
""version"": ""1.2.3""
} ]
}"),
CkanModule.FromJson(@"{
@@ -227,8 +227,8 @@ public void IsConsistent_MismatchedConflictVersion_Consistent()
""version"": ""1.0.0"",
""download"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag/download/1.01"",
""conflicts"": [ {
""name"": ""dependency"",
""version"": ""1.2.3""
""name"": ""dependency"",
""version"": ""1.2.3""
} ]
}"),
CkanModule.FromJson(@"{
@@ -253,8 +253,8 @@ public void IsConsistent_MatchedConflictVersion_Inconsistent()
""version"": ""1.0.0"",
""download"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag/download/1.01"",
""conflicts"": [ {
""name"": ""dependency"",
""version"": ""1.2.3""
""name"": ""dependency"",
""version"": ""1.2.3""
} ]
}"),
CkanModule.FromJson(@"{
@@ -268,6 +268,34 @@ public void IsConsistent_MatchedConflictVersion_Inconsistent()
Assert.IsFalse(CKAN.SanityChecker.IsConsistent(modules));
}

[Test]
public void IsConsistent_MultipleVersionsOfSelfConflictingModule_Consistent()
{
// Arrange
List<CkanModule> modules = new List<CkanModule>()
{
CkanModule.FromJson(@"{
""identifier"": ""self-conflictor"",
""version"": ""1.0.0"",
""download"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag/download/1.01"",
""conflicts"": [ {
""name"": ""self-conflictor""
} ]
}"),
CkanModule.FromJson(@"{
""identifier"": ""self-conflictor"",
""version"": ""1.2.3"",
""download"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag/download/1.01"",
""conflicts"": [ {
""name"": ""self-conflictor""
} ]
}")
};

// Act & Assert
Assert.IsTrue(CKAN.SanityChecker.IsConsistent(modules));
}

private static void TestDepends(
List<string> to_remove,
List<CkanModule> mods,

0 comments on commit 4497114

Please sign in to comment.
You can’t perform that action at this time.