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:
@@ -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;
|
||||
|
@@ -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. */
|
||||
|
Reference in New Issue
Block a user