public GitCommitTask(string message, string body, CancellationToken token, IOutputProcessor <string> processor = null) : base(token, processor ?? new SimpleOutputProcessor()) { Guard.ArgumentNotNullOrWhiteSpace(message, "message"); this.message = message; this.body = body ?? string.Empty; Name = TaskName; tempFile = NPath.GetTempFilename("GitCommitTask"); arguments = $"-c i18n.commitencoding=utf8 commit --file \"{tempFile}\""; }
public void RunCommandLineWindow(NPath workingDirectory) { var startInfo = new ProcessStartInfo { RedirectStandardInput = false, RedirectStandardOutput = false, RedirectStandardError = false, UseShellExecute = false, CreateNoWindow = false }; if (environment.IsWindows) { startInfo.FileName = "cmd"; gitEnvironment.Configure(startInfo, workingDirectory); } else if (environment.IsMac) { // we need to create a temp bash script to set up the environment properly, because // osx terminal app doesn't inherit the PATH env var and there's no way to pass it in var envVarFile = NPath.GetTempFilename(); startInfo.FileName = "open"; startInfo.Arguments = $"-a Terminal {envVarFile}"; gitEnvironment.Configure(startInfo, workingDirectory); var envVars = startInfo.EnvironmentVariables; var scriptContents = new[] { $"cd {envVars["GHU_WORKINGDIR"]}", $"PATH={envVars["GHU_FULLPATH"]}:$PATH /bin/bash" }; environment.FileSystem.WriteAllLines(envVarFile, scriptContents); Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions) 493); // -rwxr-xr-x mode (0755) } else { startInfo.FileName = "sh"; gitEnvironment.Configure(startInfo, workingDirectory); } Process.Start(startInfo); }