Support push to refs/users/self in All-Users repository
Allow a user to push to its refs/users/YY/XXXXXXX branch as refs/users/self. The user branch contains the sharded account ID in the ref name, but this is an implementation detail that should be hidden from the user. On the other hand users should be able to push to their user branch easily. A user can also push a commit on its user branch for review by pushing to refs/for/refs/users/self. Change-Id: I4883cb13d77ef181896d2f1f7c4c234994a1f24a Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -632,7 +632,7 @@ public class ReceiveCommits {
|
||||
}
|
||||
|
||||
Set<Branch.NameKey> branches = new HashSet<>();
|
||||
for (ReceiveCommand c : commands) {
|
||||
for (ReceiveCommand c : batch.getCommands()) {
|
||||
if (c.getResult() == OK) {
|
||||
if (c.getType() == ReceiveCommand.Type.UPDATE) { // aka fast-forward
|
||||
tagCache.updateFastForward(project.getNameKey(),
|
||||
@@ -890,6 +890,19 @@ public class ReceiveCommits {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (projectControl.getProjectState().isAllUsers()
|
||||
&& RefNames.REFS_USERS_SELF.equals(cmd.getRefName())) {
|
||||
final ReceiveCommand orgCmd = cmd;
|
||||
cmd = new ReceiveCommand(cmd.getOldId(), cmd.getNewId(),
|
||||
RefNames.refsUsers(user.getAccountId()), cmd.getType()) {
|
||||
@Override
|
||||
public void setResult(Result s, String m) {
|
||||
super.setResult(s, m);
|
||||
orgCmd.setResult(s, m);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Matcher m = NEW_PATCHSET.matcher(cmd.getRefName());
|
||||
if (m.matches()) {
|
||||
// The referenced change must exist and must still be open.
|
||||
@@ -1303,6 +1316,10 @@ public class ReceiveCommits {
|
||||
reject(cmd, "see help");
|
||||
return;
|
||||
}
|
||||
if (projectControl.getProjectState().isAllUsers()
|
||||
&& RefNames.REFS_USERS_SELF.equals(ref)) {
|
||||
ref = RefNames.refsUsers(user.getAccountId());
|
||||
}
|
||||
if (!rp.getAdvertisedRefs().containsKey(ref) && !ref.equals(readHEAD(repo))) {
|
||||
if (ref.startsWith(Constants.R_HEADS)) {
|
||||
String n = ref.substring(Constants.R_HEADS.length());
|
||||
|
||||
Reference in New Issue
Block a user