diff --git a/OmegaLeo.HelperLib.ConsoleApp/Program.cs b/OmegaLeo.HelperLib.ConsoleApp/Program.cs index 2b350a0..b1fca0e 100644 --- a/OmegaLeo.HelperLib.ConsoleApp/Program.cs +++ b/OmegaLeo.HelperLib.ConsoleApp/Program.cs @@ -23,13 +23,12 @@ if (changes.FolderName.IsNotNullOrEmpty()) { RecursiveOutput(new List() { 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)) + var option = 99; + + while (option != 0) { - while (option != 0) + ShowOptions(); + if (option != 99) { switch (option) { @@ -46,14 +45,17 @@ if (changes.FolderName.IsNotNullOrEmpty()) var signature = new Signature("Nuno 'Omega Leo' Diogo", "nunodiogo@omegaleo.pt", DateTimeOffset.Now); git.Commit(msg, signature); + break; + case 2: + git.Push(); break; default: Console.WriteLine("Invalid Option!"); break; } - - int.TryParse(Console.ReadLine(), out option); } + + int.TryParse(Console.ReadLine(), out option); } } else @@ -79,4 +81,13 @@ void RecursiveOutput(List folders, int depth = 0) Console.WriteLine($"{new string('\t', depth + 1)}>{Path.GetFileName(change.Path)} ({change.Status})"); } } +} + +void ShowOptions() +{ + Console.Clear(); + Console.WriteLine(new string('=', 20)); + Console.WriteLine("What do you want to do in this repository?"); + Console.WriteLine("1. Commit all changes"); + Console.WriteLine("2. Push"); } \ No newline at end of file diff --git a/OmegaLeo.HelperLib.Git/GitClient.cs b/OmegaLeo.HelperLib.Git/GitClient.cs index 1e418f9..ac12680 100644 --- a/OmegaLeo.HelperLib.Git/GitClient.cs +++ b/OmegaLeo.HelperLib.Git/GitClient.cs @@ -113,5 +113,18 @@ namespace OmegaLeo.HelperLib.Git _repo.Commit(message, author, author); } + + public void Push() + { + try { + var remote = _repo.Network.Remotes["origin"]; + var options = new PushOptions(); + var pushRefSpec = @"refs/heads/master"; + _repo.Network.Push(remote, new string[] {pushRefSpec}, options); + } + catch (Exception e) { + Console.WriteLine("Exception:RepoActions:PushChanges " + e.Message); + } + } } } \ No newline at end of file diff --git a/OmegaLeo.HelperLib.sln.DotSettings.user b/OmegaLeo.HelperLib.sln.DotSettings.user index 40fa42b..a9383eb 100644 --- a/OmegaLeo.HelperLib.sln.DotSettings.user +++ b/OmegaLeo.HelperLib.sln.DotSettings.user @@ -1,2 +1,4 @@  - ForceIncluded \ No newline at end of file + ForceIncluded + ForceIncluded + ForceIncluded \ No newline at end of file diff --git a/OmegaLeo.HelperLib/Extensions/IListExtensions.cs b/OmegaLeo.HelperLib/Extensions/IListExtensions.cs index 1d22ed4..ff19214 100644 --- a/OmegaLeo.HelperLib/Extensions/IListExtensions.cs +++ b/OmegaLeo.HelperLib/Extensions/IListExtensions.cs @@ -98,7 +98,7 @@ namespace GameDevLibrary.Extensions return values; } - public static IEnumerable DistinctBy + /*public static IEnumerable DistinctBy (this IEnumerable source, Func keySelector) { HashSet seenKeys = new HashSet(); @@ -109,7 +109,7 @@ namespace GameDevLibrary.Extensions yield return element; } } - } + }*/ // Idea obtained from TaroDev's video on things to do in Unity - https://youtu.be/Ic5ux-tpkCE?t=302