Provide more feedback for 'prohibited by Gerrit'.

This code path continues to be a source of support requests for our team.

Change-Id: I14b8cd6d492095d9e7ff5d65d7efad785cc6b4c4
This commit is contained in:
Han-Wen Nienhuys
2017-06-26 15:22:27 +02:00
parent 0e8b730c77
commit 160f0150ac
3 changed files with 53 additions and 30 deletions

View File

@@ -1070,15 +1070,19 @@ public class ReceiveCommits {
}
RefControl ctl = projectControl.controlForRef(cmd.getRefName());
if (ctl.canCreate(rp.getRepository(), obj)) {
if (!validRefOperation(cmd)) {
return;
}
validateNewCommits(ctl, cmd);
actualCommands.add(cmd);
} else {
reject(cmd, "prohibited by Gerrit: create access denied for " + cmd.getRefName());
String rejectReason = ctl.canCreate(rp.getRepository(), obj);
if (rejectReason != null) {
reject(cmd, "prohibited by Gerrit: " + rejectReason);
return;
}
if (!validRefOperation(cmd)) {
// validRefOperation sets messages, so no need to provide more feedback.
return;
}
validateNewCommits(ctl, cmd);
actualCommands.add(cmd);
}
private void parseUpdate(ReceiveCommand cmd) throws PermissionBackendException {