Пример #1
0
        /* We are using the following method for these scenarios
         * 1. Some commands compute a new commit sha, which is dependent on time and therefore
         *    won't match what is in the control repo.  For those commands, we just ensure that
         *    the errors match what we expect, but we skip comparing the output
         * 2. Using the sparse-checkout feature git will error out before checking the untracked files
         *    so the control repo will show the untracked files as being overwritten while the Scalar
         *    repo which is using the sparse-checkout will not.
         * 3. Scalar is returning not found for files that are outside the sparse-checkout and there
         *    are cases when git will delete these files during a merge outputting that it removed them
         *    which the Scalar repo did not have to remove so the message is missing that output.
         */
        protected void RunGitCommand(string command, bool ignoreErrors = false, bool checkStatus = true, string standardInput = null)
        {
            string controlRepoRoot = this.ControlGitRepo.RootPath;
            string scalarRepoRoot  = this.Enlistment.RepoRoot;

            ProcessResult expectedResult = GitProcess.InvokeProcess(controlRepoRoot, command, standardInput);
            ProcessResult actualResult   = GitHelpers.InvokeGitAgainstScalarRepo(scalarRepoRoot, command, input: standardInput);

            if (!ignoreErrors)
            {
                GitHelpers.LinesShouldMatch(command, expectedResult.Errors, actualResult.Errors);
            }

            if (command != "status" && checkStatus)
            {
                this.ValidateGitCommand("status");
            }
        }