Updated CreateRelease.cs

This commit is contained in:
MrGadget1024 2023-11-08 12:32:22 -05:00
parent ee833626c9
commit fc6a6e08e8

View File

@ -8,14 +8,14 @@
string text = File.ReadAllText(path);
// Find the whole line of the first define ending with "MIRROR_n_OR_NEWER,"
string pattern = @"\s+\""(MIRROR_(\d+)_OR_NEWER)\""\,\r\n";
string pattern = @"\s+\""(MIRROR_(\d+)_OR_NEWER)\""\,\n";
Match match = Regex.Matches(text, pattern).First();
// Remove the first define
text = text.Replace(match.Value, "");
// Find the highest version number entry, not having a comma at the end
pattern = @"\""(MIRROR_(\d+)_OR_NEWER)\""\r\n";
pattern = @"\""(MIRROR_(\d+)_OR_NEWER)\""\n";
MatchCollection matches = Regex.Matches(text, pattern);
int maxVersion = matches.Max(m => int.Parse(m.Groups[2].Value));
@ -28,7 +28,7 @@
string newDefine = $"MIRROR_{maxVersion + 1}_OR_NEWER";
// Add the new define to the end of the hashset entries, with a comma after the previous entry and properly indented
text = text.Insert(lastMatch.Index + lastMatch.Length, $",\r\n{match.Groups[1].Value}\"{newDefine}\"");
text = text.Insert(lastMatch.Index + lastMatch.Length, $",\n{match.Groups[1].Value}\"{newDefine}\"");
File.WriteAllText(path, text);