Disallow current_user/1 predicate in submit type rules
Submit type is used as part of the mergeability bit computation, which is persistent and so needs a consistent view of submit type. An informal poll of repo-discuss[1] indicated that current_user/1 is pretty much only useful for submit rules, not submit type rules. [1] https://groups.google.com/d/topic/repo-discuss/vW6XhUOkqik/discussion Change-Id: Ia938a685409025b36e16979fcafd92afbed2d91f
This commit is contained in:
@@ -20,7 +20,6 @@ import com.google.gerrit.server.AnonymousUser;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.PeerDaemonUser;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
|
||||
import com.googlecode.prolog_cafe.lang.EvaluationException;
|
||||
import com.googlecode.prolog_cafe.lang.IntegerTerm;
|
||||
@@ -47,8 +46,11 @@ public class PRED_current_user_1 extends Predicate.P1 {
|
||||
engine.setB0();
|
||||
Term a1 = arg1.dereference();
|
||||
|
||||
ChangeControl cControl = StoredValues.CHANGE_CONTROL.get(engine);
|
||||
CurrentUser curUser = cControl.getCurrentUser();
|
||||
CurrentUser curUser = StoredValues.CURRENT_USER.getOrNull(engine);
|
||||
if (curUser == null) {
|
||||
throw new EvaluationException(
|
||||
"Current user not available in this rule type");
|
||||
}
|
||||
Term resultTerm;
|
||||
|
||||
if (curUser.isIdentifiedUser()) {
|
||||
@@ -67,4 +69,4 @@ public class PRED_current_user_1 extends Predicate.P1 {
|
||||
}
|
||||
return cont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user