public void GitSetRemote() { if (!IsDestinationFolderSet()) { return; } if (_dialogService.SetRemote(out string remoteUrl)) { if (string.IsNullOrEmpty(remoteUrl)) { return; } try { if (GitProcess.Excecute(DestinationFolder, string.Format(@"remote add origin {0}", remoteUrl), out string output) == 0) { GitOutput = string.Format("Succesfully added remote server\n {0}", output); } else { GitOutput = output; } GitGetRemote(); } catch (Exception ex) { _dialogService.ShowErrorMessage("Git Status Error", ex.Message); } } }
public void GitPull() { if (!IsDestinationFolderSet()) { return; } try { IsWorking = true; GitGetRemote(); GitProcess.Excecute(DestinationFolder, "pull origin master", out string output); GitOutput = output; GitStatus(); } catch (Exception ex) { _dialogService.ShowErrorMessage("Git Pull Error", ex.Message); } finally { IsWorking = false; } }
public void GitPush() { if (!IsDestinationFolderSet()) { return; } try { StartWorking("Push"); GitGetRemote(); GitProcess.Excecute(DestinationFolder, "push --set-upstream origin master", out string output); GitOutput = output; } catch (Exception ex) { _dialogService.ShowErrorMessage("Git Push Error", ex.Message); } finally { StopWorking(); } }
public void GitStatus() { if (!IsDestinationFolderSet()) { return; } try { IsWorking = true; GitGetRemote(); GitProcess.Excecute(DestinationFolder, "status", out string output); CheckGitOutput(output); GitOutput = output; List <string> modifiedFiles = GitProcess.CheckModifiedFilesFromOutput(output); SetModifiedFiles(modifiedFiles); } catch (Exception ex) { _dialogService.ShowErrorMessage("Git Status Error", ex.Message); } finally { IsWorking = false; } }
public void GitInit() { if (!IsDestinationFolderSet()) { return; } try { IsWorking = true; // Settings SettingsHelper settingHelper = new SettingsHelper(DestinationFolder); if (!settingHelper.SettingsFolderExists()) { settingHelper.SerializeToSettingsFile(new ServerSetupModel(), new ExportFilterModel()); } // .gitignore GitHelper.CreateGitFiles(DestinationFolder); GitProcess.Excecute(DestinationFolder, "init", out string output); CheckGitOutput(output); GitOutput = output; } catch (Exception ex) { _dialogService.ShowErrorMessage("Git Init Error", ex.Message); } finally { IsWorking = false; } }
private void GitGetRemote() { try { IsWorking = true; GitProcess.Excecute(DestinationFolder, string.Format(@"config --get remote.origin.url"), out string output); GitRemoteUrl = Regex.Replace(output, @"\t|\n|\r", string.Empty); } catch (Exception ex) { _dialogService.ShowErrorMessage("Git Status Error", ex.Message); } { IsWorking = false; } }
public void GitCommit() { if (!IsDestinationFolderSet()) { return; } try { IsWorking = true; if (string.IsNullOrEmpty(GitCommitMessage)) { throw new Exception("Commit message can't be empty."); } GitProcess.Excecute(DestinationFolder, "add --all", out string output); GitOutput = output; GitProcess.Excecute(DestinationFolder, string.Format(@"commit -am ""{0}""", GitCommitMessage), out output); GitOutput = output; GitCommitMessage = string.Empty; CheckGitOutput(output); } catch (Exception ex) { _dialogService.ShowErrorMessage("Git Commit Error", ex.Message); } finally { SetModifiedFiles(new List <string>()); // Clear IsWorking = false; } }