diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Git')
| -rw-r--r-- | Software/Visual_Studio/Tango.Git/GitRepositoryManager.cs | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Git/GitRepositoryManager.cs b/Software/Visual_Studio/Tango.Git/GitRepositoryManager.cs index e7fdf8e32..7895035b9 100644 --- a/Software/Visual_Studio/Tango.Git/GitRepositoryManager.cs +++ b/Software/Visual_Studio/Tango.Git/GitRepositoryManager.cs @@ -1,6 +1,8 @@ using LibGit2Sharp; using System; using System.Collections.Generic; +using System.Diagnostics; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -13,6 +15,7 @@ namespace Tango.Git private Repository _repo; private String _pat; private String _userEmail; + private String _localFolder; public event EventHandler<TangoProgressChangedEventArgs<double>> Progress; @@ -20,7 +23,8 @@ namespace Tango.Git { _pat = personalAccessToken; _userEmail = userEmail; - _repo = new Repository(localFolder); + _localFolder = localFolder; + _repo = new Repository(_localFolder); } public void CreatePushTag(String name, String description, String userName) @@ -34,6 +38,27 @@ namespace Tango.Git }); } + public void Commit(String message) + { + ExecuteGitProcess($"commit -a -m \"{message}\""); + } + + public void Pull() + { + ExecuteGitProcess($"pull"); + } + + public void Push() + { + ExecuteGitProcess($"push"); + } + + public void Sync() + { + Pull(); + Push(); + } + private bool PushTagProgressHandlerMethod(int current, int total, long bytes) { //TODO: Implement via TangoProgress & event... @@ -124,6 +149,18 @@ namespace Tango.Git })); } + private void ExecuteGitProcess(String args) + { + Core.Components.CmdCommand command = new Core.Components.CmdCommand("git", args); + command.WorkingDir = _localFolder; + command.Timeout = TimeSpan.FromSeconds(60); + var result = command.Run().Result; + if (result.ExitCode != 0) + { + throw new IOException(result.StandardError); + } + } + public void Dispose() { _repo.Dispose(); |
