Exemplo n.º 1
0
        public ConvertedArguments Convert(GitDiffArguments arguments)
        {
            string baseSha = arguments.CommonArgs.Sha1;
            string headSha = arguments.CommonArgs.Sha2;

            throwOnEmptySha(new[] { baseSha, headSha });
            throwOnBadFilenamePair(arguments.CommonArgs.Filename1, arguments.CommonArgs.Filename2);

            Comparison comparison = getComparison(baseSha, headSha);

            createDummyPlaceHoldersForGitDiff(arguments, comparison, out bool dummyOld, out bool dummyNew);

            string filename1;
            string filename2;

            switch (arguments.Mode)
            {
            case GitDiffArguments.DiffMode.Context:
                filename1 = getFilePath(baseSha, arguments.CommonArgs.Filename1, dummyOld);
                filename2 = getFilePath(headSha, arguments.CommonArgs.Filename2, dummyNew);
                break;

            case GitDiffArguments.DiffMode.ShortStat:
                filename1 = getPath(baseSha);
                filename2 = getPath(headSha);
                break;

            case GitDiffArguments.DiffMode.NumStat:
            // Not tested.
            // NumStat Mode is used to detect renames in GitRepositoryRenameDetector.
            // FileStorageRenameDetector does not use it.

            default:
                throw new NotImplementedException();
            }

            GitDiffArguments modifiedArguments = new GitDiffArguments(arguments.Mode,
                                                                      new GitDiffArguments.CommonArguments(string.Empty, string.Empty, filename1, filename2,
                                                                                                           arguments.CommonArgs.Filter), arguments.SpecialArgs);

            return(new ConvertedArguments("git", modifiedArguments.ToString()));
        }
 async protected override Task <object> runCommandAsync(GitDiffArguments arguments)
 {
     return((await startExternalProcessAsync("git", arguments.ToString(), _path, null)).StdOut);
 }
 protected override object runCommand(GitDiffArguments arguments)
 {
     return(startExternalProcess("git", arguments.ToString(), _path, true, null).StdOut);
 }