Example #1
0
		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();
			}
		}
Example #2
0
		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);
		}
		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();
		}
Example #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;
		}
Example #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;
		}
Example #6
0
		public static Task<int> RunGitAsync(string workingDir, params string[] arguments)
		{
			ProcessRunner p = new ProcessRunner();
			p.WorkingDirectory = workingDir;
			return p.RunInOutputPadAsync(GitMessageView.Category, "git", arguments);
		}
Example #7
0
		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();
			}
		}
Example #8
0
		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;
		}
Example #9
0
		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();
		}
Example #10
0
		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);
				}
			}
		}