コード例 #1
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();
			}
		}
コード例 #2
0
ファイル: Git.cs プロジェクト: ratoy/SharpDevelop
		public static Task<int> RunGitAsync(string workingDir, params string[] arguments)
		{
			string git = FindGit();
			if (git == null)
				return Task.FromResult(9009);
			ProcessRunner p = new ProcessRunner();
			p.WorkingDirectory = workingDir;
			return p.RunInOutputPadAsync(GitMessageView.Category, git, arguments);
		}
コード例 #3
0
		void RunRestore()
		{
			var commandLine = new NuGetPackageRestoreCommandLine(solution);
			commandLine.Command = NuGetExePath.GetPath();
			
			var runner = new ProcessRunner();
			runner.WorkingDirectory = Path.GetDirectoryName(solution.FileName);
			runner.RunInOutputPadAsync(outputMessagesView.OutputCategory, commandLine.Command, commandLine.Arguments).FireAndForget();
		}
コード例 #4
0
		Stream OpenOutput(string gitExe, FileName fileName, string blobHash)
		{
			if (blobHash == null)
				return null;
			if (!File.Exists(fileName))
				return null;
			
			ProcessRunner runner = new ProcessRunner();
			runner.WorkingDirectory = fileName.GetParentDirectory();
			runner.RedirectStandardOutput = true;
			runner.Start(gitExe, "cat-file", "blob", blobHash);
			return runner.StandardOutput;
		}
コード例 #5
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;
		}
コード例 #6
0
ファイル: Git.cs プロジェクト: Paccc/SharpDevelop
		public static Task<int> RunGitAsync(string workingDir, params string[] arguments)
		{
			ProcessRunner p = new ProcessRunner();
			p.WorkingDirectory = workingDir;
			return p.RunInOutputPadAsync(GitMessageView.Category, "git", arguments);
		}
コード例 #7
0
ファイル: Git.cs プロジェクト: 2594636985/SharpDevelop
		public static async Task<int> RunGitAsync(string workingDir, params string[] arguments)
		{
			string git = FindGit();
			if (git == null)
				return 9009;
			// Wait until other git calls have finished running
			// This prevents git from failing due to a locked index when several files
			// are added concurrently
			await gitMutex.WaitAsync();
			try {
				ProcessRunner p = new ProcessRunner();
				p.WorkingDirectory = workingDir;
				return await p.RunInOutputPadAsync(GitMessageView.Category, git, arguments);
			} finally {
				gitMutex.Release();
			}
		}
コード例 #8
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;
		}
コード例 #9
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();
		}
コード例 #10
0
ファイル: GitStatusCache.cs プロジェクト: Paccc/SharpDevelop
		static async Task DisplayErrorStreamAsync(ProcessRunner runner, MessageViewCategory category)
		{
			using (var reader = runner.OpenStandardErrorReader()) {
				bool hasErrors = false;
				string line;
				while ((line = await reader.ReadLineAsync().ConfigureAwait(false)) != null) {
					if (!hasErrors) {
						hasErrors = true;
						GitMessageView.AppendLine(runner.WorkingDirectory + "> " + runner.CommandLine);
					}
					GitMessageView.AppendLine(line);
				}
			}
		}