diff --git a/src/NerdBank.GitVersioning/GitExtensions.cs b/src/NerdBank.GitVersioning/GitExtensions.cs index 41105f73..7c8e1e74 100644 --- a/src/NerdBank.GitVersioning/GitExtensions.cs +++ b/src/NerdBank.GitVersioning/GitExtensions.cs @@ -26,6 +26,14 @@ public static class GitExtensions /// private static readonly SemanticVersion SemVer0 = SemanticVersion.Parse("0.0"); + private static readonly LibGit2Sharp.CompareOptions DiffOptions = new LibGit2Sharp.CompareOptions() + { + // When calculating the height of a commit, we do not care if a file has been renamed only if it has been added or removed. + // Calculating similarities can consume significant amounts of CPU, so disable it. + Similarity = SimilarityOptions.None, + ContextLines = 0 + }; + /// /// Maximum allowable value for the /// and components. @@ -843,9 +851,9 @@ bool ContainsRelevantChanges(IEnumerable changes) => var relevantCommit = commit.Parents.Any() ? commit.Parents.Any(parent => ContainsRelevantChanges(commit.GetRepository().Diff - .Compare(parent.Tree, commit.Tree, diffInclude))) + .Compare(parent.Tree, commit.Tree, diffInclude, DiffOptions))) : ContainsRelevantChanges(commit.GetRepository().Diff - .Compare(null, commit.Tree, diffInclude)); + .Compare(null, commit.Tree, diffInclude, DiffOptions)); if (!relevantCommit) {