From a5640bcd1b8557c9a02309e9e944c7864f4008a2 Mon Sep 17 00:00:00 2001 From: Booklordofthedings Date: Mon, 2 Dec 2024 19:18:36 +0100 Subject: [PATCH] Fix document formatting a bit Warning: there is still a bug here that seemingly limits binaries to 0 --- Documentation.Rmd | 11 ++-- ManagementScript/src/BinaryTester.bf | 79 ++++++++++++++++++++++++++++ ManagementScript/src/Program.bf | 9 +++- format.data.bat | 4 ++ 4 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 ManagementScript/src/BinaryTester.bf create mode 100644 format.data.bat diff --git a/Documentation.Rmd b/Documentation.Rmd index da55c31..c5d2946 100644 --- a/Documentation.Rmd +++ b/Documentation.Rmd @@ -6,12 +6,12 @@ output: html_document ---
-system("get.data.bat") + ```{r echo=FALSE, include=FALSE, warning = FALSE} - - +system("get.data.bat") +system("format.data.bat") diffs <- read.delim("data/diffs.txt") commits <- read.csv("data/commits.txt", sep=";") @@ -75,6 +75,7 @@ Die Variablen die Ausgelesen werden beinhalten zwei Datensets mit einer 1:n Bezi - Email *//Email* - Time *//Zeitcode wann der Commit erstellt wurde* - Signed *//Ob dieser Comit mit einem Schlüssel "unterschrieben" wurde* +- Binaries *//Wie viele binäre Dateien mit dem Commit verändert wurden* #### diffs - Commit Hash *//Representiert die Id des jeweiligen Commits* @@ -103,10 +104,6 @@ Dies wird von Git benutzt, um anzuzeigen, dass es sich um eine binäre Datei han Allerdings ist die tatsache, dass eine Binäre Datei geändert wurde eine weitere Variable, die möglicherweise für das Model interessant sein könnte. -```{r} -##TODO: Cange dataset to attach "Binary files changed" to commits -``` - ## Quellen Sämtlicher Quellcode dieser Arbeit ist online verfügbar unter: diff --git a/ManagementScript/src/BinaryTester.bf b/ManagementScript/src/BinaryTester.bf new file mode 100644 index 0000000..ee452ae --- /dev/null +++ b/ManagementScript/src/BinaryTester.bf @@ -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 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(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(commithash)) + { + outputCommits.Append(scope $"{line};0\n"); + continue; + } + outputCommits.Append(scope $"{line};{binaryDiffs[scope .(commithash)]}\n"); + } + + File.WriteAllText("../data/commits.txt", outputCommits, false); + } +} \ No newline at end of file diff --git a/ManagementScript/src/Program.bf b/ManagementScript/src/Program.bf index 83673a5..b3a403f 100644 --- a/ManagementScript/src/Program.bf +++ b/ManagementScript/src/Program.bf @@ -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; diff --git a/format.data.bat b/format.data.bat new file mode 100644 index 0000000..eab5128 --- /dev/null +++ b/format.data.bat @@ -0,0 +1,4 @@ +@ECHO OFF +cd ManagementScript + +BeefBuild -run -config=Release -args bin \ No newline at end of file