Skip to content

Commit

Permalink
Merge #3805 Netkan warning when include_only doesn't match
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Mar 11, 2023
2 parents c2ffac2 + bd6b94d commit 5d7107b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file.

- [Tooling] Switch workflows from set-output to `$GITHUB_OUTPUT` (#3696 by: HebaruSan)
- [Netkan] Fix Netkan check for Ships/Script `spec_version` (#3713 by: HebaruSan; reviewed: techman83)
- [Netkan] Netkan warning when `include_only` doesn't match (#3805 by: HebaruSan; reviewed: techman83)

## v1.31.2 (Juno)

Expand Down
21 changes: 21 additions & 0 deletions Netkan/Validators/InstallsFilesValidator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Linq;

using log4net;

using CKAN.NetKAN.Model;
using CKAN.NetKAN.Services;
using CKAN.Extensions;
Expand Down Expand Up @@ -62,7 +64,26 @@ public void Validate(Metadata metadata)
var badPaths = string.Join("\r\n", duplicates);
throw new Kraken($"Multiple files attempted to install to:\r\n{badPaths}");
}

// Not a perfect check (subject to false negatives)
// but better than nothing
if (mod.install != null)
{
var unmatchedIncludeOnlys = mod.install
.Where(stanza => stanza.include_only != null)
.SelectMany(stanza => stanza.include_only)
.Distinct()
.Where(incl => !allFiles.Any(f => f.Contains(incl)))
.ToList();
if (unmatchedIncludeOnlys.Any())
{
log.WarnFormat("No matches for includes_only: {0}",
string.Join(", ", unmatchedIncludeOnlys));
}
}
}
}

private static readonly ILog log = LogManager.GetLogger(typeof(InstallsFilesValidator));
}
}

0 comments on commit 5d7107b

Please sign in to comment.