Reject %wip/%ready from non-owners of change

When a user who is not the owner of a change pushes a new patch set to
that change, prevent them from modifying the WIP state of the change.

Bug: Issue 6596
Change-Id: I4931d9cea634eedec09ba75f458e8383756d3560
This commit is contained in:
Logan Hanks
2017-06-28 15:22:02 -07:00
parent 7300429b71
commit e99188f3d9
2 changed files with 50 additions and 2 deletions

View File

@@ -202,6 +202,9 @@ public class ReceiveCommits {
+ "Squash the commits with the same Change-Id or "
+ "ensure Change-Ids are unique for each commit";
public static final String ONLY_OWNER_CAN_MODIFY_WIP =
"only change owner can modify Work-in-Progress";
private enum Error {
CONFIG_UPDATE(
"You are not allowed to perform this operation.\n"
@@ -2484,6 +2487,14 @@ public class ReceiveCommits {
}
}
if (magicBranch != null
&& (magicBranch.workInProgress || magicBranch.ready)
&& magicBranch.workInProgress != change.isWorkInProgress()
&& !user.getAccountId().equals(change.getOwner())) {
reject(inputCommand, ONLY_OWNER_CAN_MODIFY_WIP);
return false;
}
if (magicBranch != null && magicBranch.edit) {
return newEdit();
}