Fix document formatting a bit

Warning: there is still a bug here that seemingly limits binaries to 0
This commit is contained in:
Booklordofthedings 2024-12-02 19:18:36 +01:00
parent 431b6e9634
commit a5640bcd1b
4 changed files with 94 additions and 9 deletions

View file

@ -0,0 +1,79 @@
namespace ManagementScript;
using System;
using System.IO;
using System.Collections;
class BinaryTester
{
/*
Get all commits by lines
Add bin changes field to csv
go through all changes
if bin file changes exist add them
*/
Dictionary<String, uint32> binaryDiffs = new .() ~ DeleteDictionaryAndKeys!(_);
public this()
{
{
String inputDiffs = new .();
String outputDiffs = new .();
File.ReadAllText("../data/diffs.txt", inputDiffs);
var e = inputDiffs.Split('\n');
outputDiffs.Append(scope $"{e.GetNext()}\n");
lines: for(var line in e)
{
///Check if the line contains a binary diff, increment the counter and extract it
var parts = line.Split('\t');
var name = scope String(parts.GetNext());
if(!binaryDiffs.ContainsKeyAlt<StringView>(name))
binaryDiffs.Add(new .(name), 0);
for(var part in parts)
{
if(part == "-")
{
binaryDiffs[name] += 1;
continue lines;
}
}
//The line does not contain a binary diff, we can append it to the normal file
outputDiffs.Append(scope $"{line}\n");
}
File.WriteAllText("../data/diffs.txt", outputDiffs);
delete outputDiffs;
delete inputDiffs;
}
//We now have binary diffs
String inputCommits = new .();
defer delete inputCommits;
String outputCommits = new .();
defer delete outputCommits;
File.ReadAllText("../data/commits.txt", inputCommits);
var e = inputCommits.Split('\n');
outputCommits.Append(scope $"{e.GetNext().Value};binaries\n");
for(var line in e)
{
var commithash = line.Split(';').GetNext().Value;
if(!binaryDiffs.ContainsKeyAlt<StringView>(commithash))
{
outputCommits.Append(scope $"{line};0\n");
continue;
}
outputCommits.Append(scope $"{line};{binaryDiffs[scope .(commithash)]}\n");
}
File.WriteAllText("../data/commits.txt", outputCommits, false);
}
}

View file

@ -8,8 +8,14 @@ class Program
{
public static String Target = "../data/data.txt";
public static int Main()
public static int Main(String[] args)
{
if(args.Count > 0 && args[0] == "bin")
{
scope BinaryTester(); //Used for the second conversion
return 1;
}
/*
The main goal here is converting this:
@ -30,7 +36,6 @@ class Program
683248c66683c8cb3d53fd774adb072fbc6b8fdf 5 0 gmtk_2024/levels/Level_2_Rooms/level_2_room_4.tscn
*/
String input = new .(10000);
if(File.ReadAllText(Target, input) case .Err)
return -1;