Sep.Git.Tfs.Commands.TreeVerifier.Verify C# (CSharp) Method

Verify() public method

public Verify ( TfsChangesetInfo changeset, bool ignorePathCaseMismatch ) : int
changeset Sep.Git.Tfs.Core.TfsChangesetInfo
ignorePathCaseMismatch bool
return int
        public int Verify(TfsChangesetInfo changeset, bool ignorePathCaseMismatch)
        {
            Trace.TraceInformation("Comparing TFS changeset " + changeset.ChangesetId + " to git commit " + changeset.GitCommit);
            var tfsTree = changeset.Remote.GetChangeset(changeset.ChangesetId).GetTree().ToDictionary(entry => entry.FullName.ToLowerInvariant().Replace("/", @"\"));
            var gitTree = changeset.Remote.Repository.GetCommit(changeset.GitCommit).GetTree().ToDictionary(entry => entry.Entry.Path.ToLowerInvariant());

            var all = tfsTree.Keys.Union(gitTree.Keys);
            var inBoth = tfsTree.Keys.Intersect(gitTree.Keys);
            var tfsOnly = tfsTree.Keys.Except(gitTree.Keys);
            var gitOnly = gitTree.Keys.Except(tfsTree.Keys);

            var foundDiff = GitTfsExitCodes.OK;
            foreach (var file in all.OrderBy(x => x))
            {
                if (tfsTree.ContainsKey(file))
                {
                    if (gitTree.ContainsKey(file))
                    {
                        if (Compare(tfsTree[file], gitTree[file], ignorePathCaseMismatch))
                            foundDiff = Math.Max(foundDiff, GitTfsExitCodes.VerifyContentMismatch);
                    }
                    else
                    {
                        Trace.TraceInformation("Only in TFS: " + tfsTree[file].FullName);
                        foundDiff = Math.Max(foundDiff, GitTfsExitCodes.VerifyFileMissing);
                    }
                }
                else
                {
                    Trace.TraceInformation("Only in git: " + gitTree[file].FullName);
                    foundDiff = Math.Max(foundDiff, GitTfsExitCodes.VerifyFileMissing);
                }
            }
            if (foundDiff == GitTfsExitCodes.OK)
                Trace.TraceInformation("No differences!");
            return foundDiff;
        }

Usage Example

コード例 #1
0
ファイル: Verify.cs プロジェクト: jhollingworth/git-tfs
        private int Run(string commitish)
        {
            // Warn, based on core.autocrlf or core.safecrlf value?
            //  -- autocrlf=true or safecrlf=true: TFS may have CRLF where git has LF
            var parents = _globals.Repository.GetParentTfsCommits(commitish);

            if (parents.IsEmpty())
            {
                throw new GitTfsException("No TFS parents found to compare!");
            }
            foreach (var parent in parents)
            {
                _verifier.Verify(parent);
            }
            return(GitTfsExitCodes.OK);
        }
All Usage Examples Of Sep.Git.Tfs.Commands.TreeVerifier::Verify