예제 #1
0
		private void Run(ReceivePack rp, string hook) {
			var processStartInfo = new ProcessStartInfo {
				FileName = hook, UseShellExecute = false,
				WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true,
				RedirectStandardOutput = true, RedirectStandardError = true,
				RedirectStandardInput = true,
				WorkingDirectory = FullPath
			};
			var appSettings = AppSettings.Current;
			using(var process = new Process { StartInfo = processStartInfo }) {
				if(!appSettings.RunHooksSilently) {
					process.OutputDataReceived += (d, r) => { if(!String.IsNullOrWhiteSpace(r.Data)) rp.sendMessage(r.Data); };
					process.ErrorDataReceived += (d, r) => { if(!String.IsNullOrWhiteSpace(r.Data)) rp.sendError(r.Data); };
				}
				process.Start();
				process.BeginOutputReadLine();
				process.BeginErrorReadLine();
				foreach(var command in rp.getAllCommands()) {
					process.StandardInput.WriteLine(command.getOldId().Name + " " + command.getNewId().Name + " " +
						command.getRefName());
				}
				process.StandardInput.Close();
				process.WaitForExit((int) appSettings.HookTimeout.TotalMilliseconds);
				process.WaitForExit();
				process.Close();
			}
		}
예제 #2
0
 private void Run(ReceivePack rp, string hook)
 {
     var processStartInfo = new ProcessStartInfo {
         FileName = hook, UseShellExecute = false,
         WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true,
         RedirectStandardOutput = true, RedirectStandardError = true,
         WorkingDirectory = FullPath
     };
     var appSettings = AppSettings.FromAppConfig();
     using (var process = Process.Start(processStartInfo)) {
         if(!appSettings.RunHooksSilently) {
             process.OutputDataReceived += (d, r) => rp.sendMessage(r.Data);
             process.ErrorDataReceived += (d, r) => rp.sendError(r.Data);
         }
         process.BeginOutputReadLine();
         process.BeginErrorReadLine();
         process.WaitForExit((int)appSettings.HookTimeout.TotalMilliseconds);
         process.Close();
     }
 }