Dev #14

Merged
omegaleo merged 53 commits from dev into main 2026-05-15 21:04:51 +00:00
2 changed files with 59 additions and 5 deletions
Showing only changes of commit da1028388a - Show all commits
+41 -3
View File
@@ -3,6 +3,7 @@
// /media/omegaleo/Development/Library Dev/HelperLib // /media/omegaleo/Development/Library Dev/HelperLib
using GameDevLibrary.Extensions; using GameDevLibrary.Extensions;
using LibGit2Sharp;
using OmegaLeo.HelperLib.Git; using OmegaLeo.HelperLib.Git;
using OmegaLeo.HelperLib.Git.Models; using OmegaLeo.HelperLib.Git.Models;
@@ -18,9 +19,46 @@ var git = new GitClient(repo);
var changes = git.GetChanges(); var changes = git.GetChanges();
if (changes != null) if (changes.FolderName.IsNotNullOrEmpty())
{ {
RecursiveOutput(new List<ChangeFolder>() { changes }); RecursiveOutput(new List<ChangeFolder>() { changes });
Console.WriteLine(new string('=', 20));
Console.WriteLine("What do you want to do in this repository?");
Console.WriteLine("1. Commit all changes");
if (int.TryParse(Console.ReadLine(), out var option))
{
while (option != 0)
{
switch (option)
{
case 1:
Console.WriteLine("Write the commit message");
var msg = Console.ReadLine();
while (msg.IsNullOrEmpty())
{
Console.WriteLine("Empty message detected, please write a commit message...");
msg = Console.ReadLine();
}
var signature = new Signature("Nuno 'Omega Leo' Diogo", "nunodiogo@omegaleo.pt", DateTimeOffset.Now);
git.Commit(msg, signature);
break;
default:
Console.WriteLine("Invalid Option!");
break;
}
int.TryParse(Console.ReadLine(), out option);
}
}
}
else
{
Console.WriteLine("No changes found in specified repository");
} }
Console.ReadLine(); Console.ReadLine();
@@ -30,7 +68,7 @@ void RecursiveOutput(List<ChangeFolder> folders, int depth = 0)
{ {
foreach (var folder in folders) foreach (var folder in folders)
{ {
Console.WriteLine($"{new string('\t', depth + 1)}>{folder.FolderName}"); Console.WriteLine($"{new string('\t', depth)}>{folder.FolderName}");
if (folder.SubFolders.Any()) if (folder.SubFolders.Any())
{ {
RecursiveOutput(folder.SubFolders, depth + 1); RecursiveOutput(folder.SubFolders, depth + 1);
@@ -38,7 +76,7 @@ void RecursiveOutput(List<ChangeFolder> folders, int depth = 0)
foreach (var change in folder.ChangesInFolder) foreach (var change in folder.ChangesInFolder)
{ {
Console.WriteLine($"{new string('\t', depth + 2)}>{Path.GetFileName(change.Path)} ({change.Status})"); Console.WriteLine($"{new string('\t', depth + 1)}>{Path.GetFileName(change.Path)} ({change.Status})");
} }
} }
} }
+18 -2
View File
@@ -51,8 +51,6 @@ namespace OmegaLeo.HelperLib.Git
var uniqueFolderPaths = allChanges.Select(x => Path.GetDirectoryName(x.Path)).Distinct(); var uniqueFolderPaths = allChanges.Select(x => Path.GetDirectoryName(x.Path)).Distinct();
foreach (var path in uniqueFolderPaths) foreach (var path in uniqueFolderPaths)
{ {
if (path.IsNullOrEmpty()) continue; if (path.IsNullOrEmpty()) continue;
@@ -97,5 +95,23 @@ namespace OmegaLeo.HelperLib.Git
return folder; return folder;
} }
public void Commit(string message, Signature author)
{
if (HasChanges())
{
var changes = _repo.Diff.Compare<TreeChanges>();
var allChanges = new List<TreeEntryChanges>();
allChanges.AddRange(changes.Added);
allChanges.AddRange(changes.Modified);
allChanges.AddRange(changes.Deleted);
var filePaths = allChanges.Select(x => x.Path).Where(x => x.IsNotNullOrEmpty());
Commands.Stage(_repo, filePaths);
}
_repo.Commit(message, author, author);
}
} }
} }