82 lines
2.3 KiB
C#
82 lines
2.3 KiB
C#
// See https://aka.ms/new-console-template for more information
|
|
|
|
// /media/omegaleo/Development/Library Dev/HelperLib
|
|
|
|
using GameDevLibrary.Extensions;
|
|
using LibGit2Sharp;
|
|
using OmegaLeo.HelperLib.Git;
|
|
using OmegaLeo.HelperLib.Git.Models;
|
|
|
|
Console.WriteLine("Insert repo path to check changes:");
|
|
var repo = Console.ReadLine();
|
|
|
|
if (repo.IsNullOrEmpty())
|
|
{
|
|
repo = "/media/omegaleo/Development/Library Dev/HelperLib";
|
|
}
|
|
|
|
var git = new GitClient(repo);
|
|
|
|
var changes = git.GetChanges();
|
|
|
|
if (changes.FolderName.IsNotNullOrEmpty())
|
|
{
|
|
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();
|
|
|
|
|
|
void RecursiveOutput(List<ChangeFolder> folders, int depth = 0)
|
|
{
|
|
foreach (var folder in folders)
|
|
{
|
|
Console.WriteLine($"{new string('\t', depth)}>{folder.FolderName}");
|
|
if (folder.SubFolders.Any())
|
|
{
|
|
RecursiveOutput(folder.SubFolders, depth + 1);
|
|
}
|
|
|
|
foreach (var change in folder.ChangesInFolder)
|
|
{
|
|
Console.WriteLine($"{new string('\t', depth + 1)}>{Path.GetFileName(change.Path)} ({change.Status})");
|
|
}
|
|
}
|
|
} |