/// <summary> /// Executes a specified command on the Git client. /// </summary> /// <param name="command">The command to execute.</param> /// <returns>A <see cref="ScmClientResult"/> that contains the execution result.</returns> protected override ScmClientResult ExecuteCore(String command) { // Create process start information ProcessStartInfo psi = new ProcessStartInfo() { Arguments = command, CreateNoWindow = true, FileName = Path.Combine(ExecutablePath, ExecutableName), RedirectStandardError = true, RedirectStandardOutput = true, UseShellExecute = false, WorkingDirectory = WorkingDirectory }; ScmClientResult result = ScmClientResult.Empty; // Create Git client process and run it using (Process p = Process.Start(psi)) { p.WaitForExit(); result = new ScmClientResult(p.StandardOutput.ReadToEnd(), p.StandardError.ReadToEnd(), p.ExitCode); } return result; }
/// <summary> /// Tries to execute a specified command on the client. /// </summary> /// <param name="command">The command to execute.</param> /// <param name="result">The <see cref="ScmClientResult"/> variable that receives the result /// of the exection.</param> /// <returns>True if the execution was successful; otherwise, false.</returns> public Boolean TryExecute(String command, out ScmClientResult result) { try { result = Execute(command); return true; } catch { result = ScmClientResult.Empty; return false; } }