AppHarbor.GitCommand.Execute C# (CSharp) Method

Execute() public method

public Execute ( string command ) : IList
command string
return IList
        public virtual IList<string> Execute(string command)
        {
            var processArguments = new StringBuilder();

            processArguments.AppendFormat("/C ");
            processArguments.AppendFormat("\"{0}\" ", _gitExecutable.FullName);
            processArguments.AppendFormat("{0} ", command);

            var process = new Process
            {
                StartInfo = new ProcessStartInfo("cmd.exe")
                {
                    Arguments = processArguments.ToString(),
                    CreateNoWindow = true,
                    RedirectStandardError = true,
                    RedirectStandardOutput = true,
                    UseShellExecute = false,
                    WorkingDirectory = CurrentDirectory.FullName,
                },
            };

            using (process)
            {
                process.Start();
                process.WaitForExit();
                string error = process.StandardError.ReadToEnd();
                if (!string.IsNullOrEmpty(error))
                {
                    throw new GitCommandException(error);
                }

                var output = new List<string>();
                while (process.StandardOutput.Peek() > 0)
                {
                    output.Add(process.StandardOutput.ReadLine());
                }

                return output;
            }
        }