Make project state check in UPDATE explicit

The majority of code in {Project,Ref,Change}Control is now about
permissions, but not all. Exceptions include checks for a project's
state. This is confusing, because users are presented with an exception
telling them that they lack some kind of permission while the real
reason for the failed operation is that the project's current state
doesn't permit the operation.

This is part of a series of commits to remove all project state checks
from *Control classes and make explicit checks instead.

Change-Id: Ie50735695b0eaefc0ba3d6508504b05daefebc7e
This commit is contained in:
Patrick Hiesel
2018-01-12 10:09:05 +01:00
parent 7e16e21f0e
commit dc8f96a069
2 changed files with 4 additions and 1 deletions

View File

@@ -1060,6 +1060,9 @@ class ReceiveCommits {
} catch (AuthException err) {
ok = false;
}
if (!projectState.statePermitsWrite()) {
reject(cmd, "prohibited by Gerrit: project state does not permit write");
}
if (ok) {
if (isHead(cmd) && !isCommit(cmd)) {
return;

View File

@@ -224,7 +224,7 @@ class RefControl {
return false;
}
}
return canPerform(Permission.PUSH) && isProjectStatePermittingWrite();
return canPerform(Permission.PUSH);
}
/** @return true if the user can rewind (force push) the reference. */