in java/com/google/gerrit/server/approval/ApprovalInference.java [123:312]
private boolean canCopyBasedOnBooleanLabelConfigs(
ProjectState project,
PatchSetApproval psa,
PatchSet.Id psId,
ChangeKind kind,
LabelType type,
@Nullable Map<String, ModifiedFile> baseVsCurrentDiff,
@Nullable Map<String, ModifiedFile> baseVsPriorDiff,
@Nullable Map<String, ModifiedFile> priorVsCurrentDiff) {
int n = psa.key().patchSetId().get();
checkArgument(n != psId.get());
if (type.isCopyMinScore() && type.isMaxNegative(psa)) {
logger.atFine().log(
"veto approval %s on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because the label has set copyMinScore = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
project.getName());
return true;
} else if (type.isCopyMaxScore() && type.isMaxPositive(psa)) {
logger.atFine().log(
"max approval %s on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because the label has set copyMaxScore = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
project.getName());
return true;
} else if (type.isCopyAnyScore()) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because the label has set copyAnyScore = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
project.getName());
return true;
} else if (type.getCopyValues().contains(psa.value())) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because the label has set copyValue = %d on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
psa.value(),
project.getName());
return true;
} else if (type.isCopyAllScoresIfListOfFilesDidNotChange()
&& listOfFilesUnchangedPredicate.match(
baseVsCurrentDiff, baseVsPriorDiff, priorVsCurrentDiff)) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because the label has set "
+ "copyAllScoresIfListOfFilesDidNotChange = true on "
+ "project %s and list of files did not change (maybe except a rename, which is "
+ "still the same file).",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
project.getName());
return true;
}
switch (kind) {
case MERGE_FIRST_PARENT_UPDATE:
if (type.isCopyAllScoresOnMergeFirstParentUpdate()) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because change kind is %s and the label has set"
+ " copyAllScoresOnMergeFirstParentUpdate = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
kind,
project.getName());
return true;
}
return false;
case NO_CODE_CHANGE:
if (type.isCopyAllScoresIfNoCodeChange()) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because change kind is %s and the label has set"
+ " copyAllScoresIfNoCodeChange = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
kind,
project.getName());
return true;
}
return false;
case TRIVIAL_REBASE:
if (type.isCopyAllScoresOnTrivialRebase()) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because change kind is %s and the label has set"
+ " copyAllScoresOnTrivialRebase = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
kind,
project.getName());
return true;
}
return false;
case NO_CHANGE:
if (type.isCopyAllScoresIfNoChange()) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because change kind is %s and the label has set"
+ " copyAllScoresIfNoCodeChange = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
kind,
project.getName());
return true;
}
if (type.isCopyAllScoresOnTrivialRebase()) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because change kind is %s and the label has set"
+ " copyAllScoresOnTrivialRebase = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
kind,
project.getName());
return true;
}
if (type.isCopyAllScoresOnMergeFirstParentUpdate()) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because change kind is %s and the label has set"
+ " copyAllScoresOnMergeFirstParentUpdate = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
kind,
project.getName());
return true;
}
if (type.isCopyAllScoresIfNoCodeChange()) {
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d can be copied"
+ " to patch set %d because change kind is %s and the label has set"
+ " copyAllScoresIfNoCodeChange = true on project %s",
psa.value(),
psa.label(),
n,
psa.key().patchSetId().changeId().get(),
psId.get(),
kind,
project.getName());
return true;
}
return false;
case REWORK:
default:
logger.atFine().log(
"approval %d on label %s of patch set %d of change %d cannot be copied"
+ " to patch set %d because change kind is %s",
psa.value(), psa.label(), n, psa.key().patchSetId().changeId().get(), psId.get(), kind);
return false;
}
}