internal FileStorageGitCommandService(
     IExternalProcessManager operationManager, string path, IFileStorage fileStorage)
     : base(operationManager)
 {
     _fileCache         = fileStorage.FileCache;
     _path              = path;
     _argumentConverter = new FileStorageArgumentConverter(fileStorage);
     RenameDetector     = new FileStorageRenameDetector(fileStorage);
 }
 internal GitRepositoryUpdater(
     ISynchronizeInvoke synchronizeInvoke,
     IGitRepository gitRepository,
     IExternalProcessManager operationManager,
     UpdateMode mode,
     Action onCloned,
     Action <string> onFetched)
 {
     _gitRepository   = gitRepository;
     _updaterInternal = new GitRepositoryUpdaterInternal(synchronizeInvoke, gitRepository,
                                                         operationManager, mode, onCloned, onFetched);
 }
Example #3
0
 /// <summary>
 /// Bind to the specific GitRepository object
 /// </summary>
 internal GitRepositoryUpdaterInternal(
     ISynchronizeInvoke synchronizeInvoke,
     IGitRepository gitRepository,
     IExternalProcessManager operationManager,
     UpdateMode mode,
     Action onCloned,
     Action <string> onFetched)
 {
     _synchronizeInvoke = synchronizeInvoke;
     _gitRepository     = gitRepository;
     _processManager    = operationManager;
     _updateMode        = mode;
     _onCloned          = onCloned;
     _onFetched         = onFetched;
 }
        public async Task ReturnsOkResultWhenProcessExitCodeIs0()
        {
            Mock <ILogger>          loggingMock   = new Mock <ILogger>();
            ProcessRunResult        processResult = CreateProcessRunResult(0);
            IExternalProcessManager externalProcessManagerMockObject = CreateExternalProcessManagerMock(processResult).Object;
            RunExternalProcess      runExternalProcessFunction       = CreateRunExternalProcess(externalProcessManagerMockObject);

            IActionResult result = await runExternalProcessFunction.Run(
                CreateHttpRequest(), loggingMock.Object,
                new ExecutionContext()
            {
                FunctionAppDirectory = testBaseDirectory
            });

            result.Should().BeOfType <OkObjectResult>();
            ((OkObjectResult)result).Value.Should().Be($"Success! Process output: {processResult.Output}");
        }
        public async Task CallsInitialiseOnExternalProcessManagerWithExitCodeQueryStringParameter()
        {
            Mock <ILogger>   loggingMock   = new Mock <ILogger>();
            ProcessRunResult processResult = CreateProcessRunResult(new Random().Next(1, int.MaxValue));
            Mock <IExternalProcessManager> externalProcessManagerMock       = CreateExternalProcessManagerMock(processResult);
            IExternalProcessManager        externalProcessManagerMockObject = externalProcessManagerMock.Object;
            string             expectedExitCode           = "testExitCode";
            RunExternalProcess runExternalProcessFunction = CreateRunExternalProcess(externalProcessManagerMockObject);

            IActionResult result = await runExternalProcessFunction.Run(
                CreateHttpRequest(expectedExitCode), loggingMock.Object,
                new ExecutionContext()
            {
                FunctionAppDirectory = testBaseDirectory
            });

            externalProcessManagerMock.Verify(mock => mock.Initialize(testBaseDirectory, expectedExitCode, true));
        }
        public async Task ReturnsErrorResultWhenProcessExitCodeIsNot0()
        {
            Mock <ILogger>          loggingMock   = new Mock <ILogger>();
            ProcessRunResult        processResult = CreateProcessRunResult(new Random().Next(1, int.MaxValue));
            IExternalProcessManager externalProcessManagerMockObject = CreateExternalProcessManagerMock(processResult).Object;
            RunExternalProcess      runExternalProcessFunction       = CreateRunExternalProcess(externalProcessManagerMockObject);

            IActionResult result = await runExternalProcessFunction.Run(
                CreateHttpRequest(), loggingMock.Object,
                new ExecutionContext()
            {
                FunctionAppDirectory = testBaseDirectory
            });

            result.Should().BeOfType <ObjectResult>();
            ObjectResult objectResult = (ObjectResult)result;

            objectResult.Value.Should().Be($"Fail! Process error: {processResult.Error}");
            objectResult.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError);
        }
Example #7
0
        async public static Task <bool> DoesEntityExistAtPathAsync(
            IExternalProcessManager operationManager, string path, string entity)
        {
            string arguments = String.Format("cat-file -t {0}", entity);

            try
            {
                ExternalProcess.AsyncTaskDescriptor descriptor =
                    operationManager?.CreateDescriptor("git", arguments, path, null, null);
                if (descriptor == null)
                {
                    return(false);
                }

                await operationManager.Wait(descriptor);

                return(descriptor.StdErr.Count() == 0);
            }
            catch (Exception) // Exception type does not matter
            {
                return(false);
            }
        }
 internal GitCommandService(IExternalProcessManager processManager)
 {
     _processManager         = processManager;
     FullContextDiffProvider = new FullContextDiffProvider(this);
     GitDiffAnalyzer         = new GitDiffAnalyzer(this);
 }
 public RunExternalProcess(IExternalProcessManager processManager)
 {
     this.processManager = processManager;
 }
 internal NativeGitCommandService(IExternalProcessManager operationManager, string path)
     : base(operationManager)
 {
     _path          = path;
     RenameDetector = new GitRepositoryRenameDetector(this);
 }
 private static RunExternalProcess CreateRunExternalProcess(IExternalProcessManager externalProcessManagerMockObject)
 {
     return(new RunExternalProcess(externalProcessManagerMockObject));
 }
Example #12
0
 internal GitCommandService(IExternalProcessManager processManager)
 {
     _processManager = processManager;
 }