public static ParseProgress ( string line, double &percentage, double &speed, string &information ) : ErrorStatus | ||
line | string | |
percentage | double | |
speed | double | |
information | string | |
return | ErrorStatus |
bool ReadStream(GitCommand command) { StreamReader output_stream = command.StandardError; if (StorageType == StorageType.LargeFiles) { output_stream = command.StandardOutput; } double percentage = 0; double speed = 0; string information = ""; while (!output_stream.EndOfStream) { string line = output_stream.ReadLine(); ErrorStatus error = GitCommand.ParseProgress(line, out percentage, out speed, out information); if (error != ErrorStatus.None) { Error = error; information = line; command.Kill(); command.Dispose(); Logger.LogInfo("Git", Name + " | Error status changed to " + Error); return(false); } OnProgressChanged(percentage, speed, information); } return(true); }
public override bool Fetch() { if (!base.Fetch()) { return(false); } StorageType?storage_type = DetermineStorageType(); if (storage_type == null) { return(false); } FetchedRepoStorageType = (StorageType)storage_type; string git_clone_command = "clone --progress --no-checkout"; if (!FetchPriorHistory) { git_clone_command += " --depth=1"; } if (storage_type == StorageType.LargeFiles) { git_clone_command = "lfs clone --progress --no-checkout"; } git_clone = new GitCommand(Configuration.DefaultConfiguration.TmpPath, string.Format("{0} \"{1}\" \"{2}\"", git_clone_command, RemoteUrl, TargetFolder), auth_info); git_clone.StartInfo.RedirectStandardError = true; git_clone.Start(); StreamReader output_stream = git_clone.StandardError; if (FetchedRepoStorageType == StorageType.LargeFiles) { output_stream = git_clone.StandardOutput; } double percentage = 0; double speed = 0; string information = ""; while (!output_stream.EndOfStream) { string line = output_stream.ReadLine(); ErrorStatus error = GitCommand.ParseProgress(line, out percentage, out speed, out information); if (error != ErrorStatus.None) { IsActive = false; git_clone.Kill(); git_clone.Dispose(); return(false); } OnProgressChanged(percentage, speed, information); } git_clone.WaitForExit(); if (git_clone.ExitCode != 0) { return(false); } Thread.Sleep(500); OnProgressChanged(100, 0, ""); Thread.Sleep(500); return(true); }