Merge "Clarify error msg when user's not allowed to '--force push'."

This commit is contained in:
Shawn Pearce
2011-12-07 19:05:30 -08:00
committed by gerrit code review
4 changed files with 6 additions and 9 deletions

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.common.data;
public class PermissionRule implements Comparable<PermissionRule> {
public static final String FORCE_PUSH = "Force Push";
public static enum Action {
ALLOW, DENY, BLOCK,

View File

@@ -137,6 +137,7 @@ public class PermissionRuleEditor extends Composite implements
String ref = section.getName();
canForce = !ref.startsWith("refs/for/") && !ref.startsWith("^refs/for/");
}
force.setText(PermissionRule.FORCE_PUSH);
force.setVisible(canForce);
force.setEnabled(!readOnly);

View File

@@ -80,14 +80,7 @@ limitations under the License.
<q:Hyperlink ui:field='groupNameLink' styleName='{style.groupName}'/>
<span ui:field='groupNameSpan' styleName='{style.groupName}'/>
<g:CheckBox
ui:field='force'
addStyleNames='{style.forcePush}'
text='Force Push'>
<ui:attribute name='text'/>
</g:CheckBox>
<g:CheckBox ui:field='force' addStyleNames='{style.forcePush}'/>
<g:Anchor
ui:field='deleteRule'
href='javascript:void'

View File

@@ -19,6 +19,7 @@ import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.ApprovalType;
import com.google.gerrit.common.data.ApprovalTypes;
import com.google.gerrit.common.data.Capable;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.common.errors.NoSuchAccountException;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.ApprovalCategory;
@@ -597,7 +598,8 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
if (ctl.canForceUpdate()) {
// Let the core receive process handle it
} else {
cmd.setResult(ReceiveCommand.Result.REJECTED_NONFASTFORWARD);
cmd.setResult(ReceiveCommand.Result.REJECTED_NONFASTFORWARD, " need '"
+ PermissionRule.FORCE_PUSH + "' privilege.");
}
}