protected override void Create(string path, string root, FilterMode mode) { if (!lfsManager.IsEnabled) { return; } try { var process = new Process(); var startInfo = new ProcessStartInfo { FileName = "git-lfs", WorkingDirectory = gitManager.GetCurrentRepoPath(), RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true, UseShellExecute = false }; // launch git-lfs smudge or clean switch (mode) { case FilterMode.Smudge: startInfo.Arguments = "smudge"; break; case FilterMode.Clean: startInfo.Arguments = "clean"; break; default: throw new ArgumentOutOfRangeException("mode"); } process.StartInfo = startInfo; if (!process.Start()) { logger.LogFormat(LogType.Error, "Cound not start lfs process of type: {0} for path: {1}", mode, path); } else { if (processes.ContainsKey(path)) { logger.LogFormat(LogType.Error, "There is already lfs process for path: {0}", path); return; } processes.Add(path, process); modes.Add(path, mode); } } catch (Exception e) { logger.Log(LogType.Error, "LFS Create Error!"); logger.LogException(e); } }
public bool CallProccess(string name, string parameters) { string fullPath = GitExternalManager.GetFullPath(name); if (fullPath != null) { ProcessStartInfo startInfo = new ProcessStartInfo { CreateNoWindow = false, UseShellExecute = false, FileName = fullPath, WorkingDirectory = gitManager.GetCurrentRepoPath(), WindowStyle = ProcessWindowStyle.Hidden, RedirectStandardOutput = true, Arguments = parameters }; try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close. using (Process exeProcess = Process.Start(startInfo)) { if (exeProcess == null) { return(false); } exeProcess.WaitForExit(); return(true); } } catch { return(false); } } return(false); }