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

Sort exported modpack relationships by identifier #3499

Merged
merged 1 commit into from
Jan 19, 2022

Conversation

HebaruSan
Copy link
Member

Problem

When you export a modpack into a .ckan file, the mods are in a non-deterministic order. Since the ordering changes from one export to the next, it is difficult to notice changes or track them with code tools like git or diff.

First reported here:

https://forum.kerbalspaceprogram.com/index.php?/topic/205890-%D1%81%D0%BE%D1%80%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D1%89%D0%B8%D0%BA-ckan-%D1%84%D0%B0%D0%B9%D0%BB%D0%B0/

(Found while searching the forum for "CKAN" because I don't have the official CKAN forum thread bookmarked.)

Cause

The order is the order of Registry.Installed(), which is a Dictionary with the identifiers as keys. This is non-deterministic.

Changes

Now we perform a case-insensitive sort by identifier after filtering the sequence and before making the RelationshipDescriptor objects. This should make the ordering consistent.

Documentation for StringComparer.OrdinalIgnoreCase:

https://docs.microsoft.com/en-us/dotnet/api/system.stringcomparer.ordinalignorecase?view=netframework-4.7.2

The StringComparer returned by the OrdinalIgnoreCase property treats the characters in the strings to compare as if they were converted to uppercase using the conventions of the invariant culture, and then performs a simple byte comparison that is independent of language. This is most appropriate when comparing strings that are generated programmatically or when comparing case-insensitive resources such as paths and filenames.

@HebaruSan HebaruSan added Enhancement Easy This is easy to fix Core (ckan.dll) Issues affecting the core part of CKAN Pull request Registry Issues affecting the registry labels Dec 27, 2021
@DasSkelett DasSkelett merged commit 0651323 into KSP-CKAN:master Jan 19, 2022
@HebaruSan HebaruSan deleted the fix/modpack-sort branch January 19, 2022 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core (ckan.dll) Issues affecting the core part of CKAN Easy This is easy to fix Enhancement Pull request Registry Issues affecting the registry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants