in git-server/src/main/java/jetbrains/buildServer/buildTriggers/vcs/git/GitCollectChangesPolicy.java [333:394]
private Result computeRevisionByCheckoutRules(@NotNull String startRevision,
@NotNull Collection<String> stopRevisions,
@NotNull CheckoutRules rules,
@Nullable Set<String> visited,
@NotNull OperationContext context,
@NotNull GitVcsRoot gitRoot) throws VcsException {
if (!stopRevisions.isEmpty() &&
myVcs.isNativeGitOperationEnabled(gitRoot) &&
rules.getExcludeRules().isEmpty() &&
TeamCityProperties.getBooleanOrTrue(REVISION_BY_CHECKOUT_RULES_USE_LOG_COMMAND)) {
// this revWalk helps us to compute reachable stop revisions, we do not need to apply checkout rules as we already checked that
// there are no interesting commits between start and stop revisions
CheckoutRulesRevWalk revWalk = new CheckoutRulesRevWalk(myConfig, context, rules) {
@Override
protected boolean isCurrentCommitIncluded() {
return false;
}
};
try {
Boolean hasInterestingCommits = null;
Collection<String> paths = new HashSet<>();
try {
for (IncludeRule r: rules.getIncludeRules()) {
paths.add(r.getFrom());
}
Set<String> stopRevisionsParents = getParentsOfStopRevisions(stopRevisions, context, revWalk);
if (!stopRevisionsParents.isEmpty()) {
hasInterestingCommits = hasCommitsAffectingPaths(startRevision, stopRevisionsParents, paths, context, gitRoot);
}
} catch (Exception e) {
LOG.warnAndDebugDetails("Could not compute changed paths from: " + startRevision + " with stop revisions: " + stopRevisions + " in VCS root: " + gitRoot.toString(), e);
}
if (hasInterestingCommits != null && !hasInterestingCommits) {
try {
// only traverse DAG to compute visited and reachable stop revisions without checking the checkout rules
return computeResult(startRevision, stopRevisions, visited, gitRoot, revWalk);
} catch (Exception e) {
throw context.wrapException(e);
}
}
} finally {
revWalk.close();
revWalk.dispose();
}
}
CheckoutRulesRevWalk revWalk = null;
try {
revWalk = new CheckoutRulesRevWalk(myConfig, context, rules);
return computeResult(startRevision, stopRevisions, visited, gitRoot, revWalk);
} catch (Exception e) {
throw context.wrapException(e);
} finally {
if (revWalk != null) {
revWalk.close();
revWalk.dispose();
}
}
}