/// <summary> /// Run a git command, running onComplete when process completes. /// </summary> /// <param name="command"></param> /// <param name="onComplete"></param> /// <param name="onError"></param> public static void RunCommand(string command, Action <CommandOutput> onComplete) { string outputData = null; string errorData = null; if (GitGudSettings.GetBool("debug")) { UnityEngine.Debug.Log("Running command " + command); } RunCommandInternal(command, (output) => { //Output stream if (output != null) { if (outputData == null) { outputData = output; } else { outputData += "\n" + output; } } }, (error) => { //Error stream if (error != null) { //Special case: Stop line endings error if (error.Contains("LF will be replaced by CRLF")) { return; } if (error.Contains("The file will have its original line endings in your working directory")) { return; } if (errorData == null) { errorData = error; } else { errorData += "\n" + error; } } }, () => { //Debugging if (GitGudSettings.GetBool("debug") && outputData != null) { UnityEngine.Debug.Log("<color=blue>Output:</color>" + outputData); } if (GitGudSettings.GetBool("debug") && errorData != null) { UnityEngine.Debug.Log("<color=red>Error:</color>" + errorData); } CommandOutput output = new CommandOutput(outputData, errorData); if (onComplete != null) { onComplete(output); } } ); }
//Converts a path relative to the repo to an absolute path public static string RepoPathToAbsolutePath(string repoPath) { return(System.IO.Path.Combine(GitGudSettings.GetString("repo_path"), repoPath)); }