コード例 #1
0
		internal static async Task<string> GetBlobHashAsync(string gitExe, FileName fileName)
		{
			if (!File.Exists(fileName))
				return null;
			
			ProcessRunner runner = new ProcessRunner();
			runner.WorkingDirectory = fileName.GetParentDirectory();
			runner.RedirectStandardOutput = true;
			runner.Start(gitExe, "ls-tree", "HEAD", fileName.GetFileName());
			using (var reader = runner.OpenStandardOutputReader()) {
				string firstLine = await reader.ReadLineAsync().ConfigureAwait(false);
				if (firstLine != null) {
					string[] parts = firstLine.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
					if (parts.Length >= 3) {
						if (parts[2].Length == 40)
							return parts[2];
					}
				}
			}
			return null;
		}
コード例 #2
0
ファイル: GitStatusCache.cs プロジェクト: Paccc/SharpDevelop
		static void GitGetFiles(string wcRoot, GitStatusSet statusSet)
		{
			string git = Git.FindGit();
			if (git == null)
				return;
			
			using (ProcessRunner runner = new ProcessRunner()) {
				runner.WorkingDirectory = DirectoryName.Create(wcRoot);
				runner.RedirectStandardOutput = true;
				runner.RedirectStandardError = true;
				runner.Start(git, "ls-files");
				
				// process stderr in background
				var errorTask = DisplayErrorStreamAsync(runner, GitMessageView.Category);
				// process stderr on current thread:
				using (var reader = runner.OpenStandardOutputReader()) {
					string line;
					while ((line = reader.ReadLine()) != null) {
						if (line.Length > 0) {
							statusSet.AddEntry(line, GitStatus.OK);
						}
					}
				}
				errorTask.Wait();
			}
		}
コード例 #3
0
ファイル: NAntRunner.cs プロジェクト: 2594636985/SharpDevelop
		async Task<int> RunNAnt()
		{
			string[] arguments = GetArguments();
			
			runner = new ProcessRunner();
			runner.WorkingDirectory = workingDirectory;
			
			runner.RedirectStandardOutputAndErrorToSingleStream = true;
			runner.Start(nantFileName, arguments);
			
			AbstractRunNAntCommand.Category.AppendLine(runner.CommandLine);
			
			var writer = new NAntMessageViewCategoryTextWriter(AbstractRunNAntCommand.Category);
			using (TextReader reader = runner.OpenStandardOutputReader()) {
				await reader.CopyToAsync(writer);
			}
			
			OnNAntStarted();
			
			await runner.WaitForExitAsync();
			AbstractRunNAntCommand.Category.AppendLine(StringParser.Parse("${res:XML.MainMenu.ToolMenu.ExternalTools.ExitedWithCode} " + runner.ExitCode));
			
			OnNAntExited(writer.Output, String.Empty, runner.ExitCode);
			
			return runner.ExitCode;
		}
コード例 #4
0
ファイル: GitStatusCache.cs プロジェクト: Paccc/SharpDevelop
		static void GitGetStatus(string wcRoot, GitStatusSet statusSet)
		{
			string git = Git.FindGit();
			if (git == null)
				return;
			
			ProcessRunner runner = new ProcessRunner();
			runner.WorkingDirectory = DirectoryName.Create(wcRoot);
			runner.RedirectStandardOutput = true;
			runner.RedirectStandardError = true;
			runner.Start(git, "status", "--porcelain", "--untracked-files=no");
			// process stderr in background
			var errorTask = DisplayErrorStreamAsync(runner, GitMessageView.Category);
			// process stderr on current thread:
			using (var reader = runner.OpenStandardOutputReader()) {
				string line;
				while ((line = reader.ReadLine()) != null) {
					if (line.Length > 0) {
						Match m = statusParseRegex.Match(line);
						if (m.Success) {
							statusSet.AddEntry(m.Groups[2].Value, StatusFromText(m.Groups[1].Value));
						} else {
							GitMessageView.AppendLine("unknown git status output: " + line);
						}
					}
				}
			}
			errorTask.Wait();
		}