Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  ReceiveCommits: Don't instantiate BranchCommitValidator repeatedly
  PermissionRange: Interpret allowMin > allowMax as disallow

Change-Id: Ia18620a2e4daba4dcd4519cb3d3670a87e229ef2
This commit is contained in:
Marco Miller
2019-06-27 10:15:27 -04:00
3 changed files with 13 additions and 3 deletions

View File

@@ -70,8 +70,8 @@ public class PermissionRange implements Comparable<PermissionRange> {
this.min = min;
this.max = max;
} else {
this.min = max;
this.max = min;
this.min = 0;
this.max = 0;
}
}

View File

@@ -3084,6 +3084,7 @@ class ReceiveCommits {
}
}
BranchCommitValidator validator = commitValidatorFactory.create(projectState, branch, user);
RevWalk walk = receivePack.getRevWalk();
walk.reset();
walk.sort(RevSort.NONE);
@@ -3110,7 +3111,6 @@ class ReceiveCommits {
continue;
}
BranchCommitValidator validator = commitValidatorFactory.create(projectState, branch, user);
if (!validator.validCommit(
walk.getObjectReader(), cmd, c, false, messages, rejectCommits, null, skipValidation)) {
break;

View File

@@ -563,6 +563,16 @@ public class RefControlTest extends GerritBaseTests {
assertCannotUpdate("refs/tags/V10", u);
}
@Test
public void blockPartialRangeLocally() {
block(local, LABEL + "Code-Review", +1, +2, DEVS, "refs/heads/master");
ProjectControl u = user(local, DEVS);
PermissionRange range = u.controlForRef("refs/heads/master").getRange(LABEL + "Code-Review");
assertCannotVote(2, range);
}
@Test
public void blockLabelRange_ParentBlocksChild() {
allow(local, LABEL + "Code-Review", -2, +2, DEVS, "refs/heads/*");