Merge branch 'stable-2.7'
* stable-2.7: Fix: failed to validate Change-Id of some new patch-sets pushed by 'refs/changes' Conflicts: gerrit-server/src/main/java/com/google/gerrit/server/ChangeUtil.java gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java Change-Id: I89ffdf132ad320215b00d0628c07797157a1b925
This commit is contained in:
@@ -43,6 +43,7 @@ import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.project.RefControl;
|
||||
import com.google.gerrit.server.util.IdGenerator;
|
||||
import com.google.gerrit.server.util.MagicBranch;
|
||||
import com.google.gwtorm.server.OrmConcurrencyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
||||
@@ -252,11 +253,14 @@ public class ChangeUtil {
|
||||
changeInserterFactory.create(refControl, change, revertCommit);
|
||||
PatchSet ps = ins.getPatchSet();
|
||||
|
||||
String ref = refControl.getRefName();
|
||||
final String cmdRef =
|
||||
MagicBranch.NEW_PUBLISH_CHANGE
|
||||
+ ref.substring(ref.lastIndexOf('/') + 1);
|
||||
CommitReceivedEvent commitReceivedEvent =
|
||||
new CommitReceivedEvent(new ReceiveCommand(ObjectId.zeroId(),
|
||||
revertCommit.getId(), ps.getRefName()), refControl
|
||||
.getProjectControl().getProject(), refControl.getRefName(),
|
||||
revertCommit, user);
|
||||
revertCommit.getId(), cmdRef), refControl.getProjectControl()
|
||||
.getProject(), refControl.getRefName(), revertCommit, user);
|
||||
|
||||
try {
|
||||
commitValidators.validateForGerritCommits(commitReceivedEvent);
|
||||
|
@@ -240,9 +240,12 @@ public class PatchSetInserter {
|
||||
private void validate() throws InvalidChangeOperationException {
|
||||
CommitValidators cv = commitValidatorsFactory.create(refControl, sshInfo, git);
|
||||
|
||||
String refName = patchSet.getRefName();
|
||||
CommitReceivedEvent event = new CommitReceivedEvent(
|
||||
new ReceiveCommand(ObjectId.zeroId(), commit.getId(),
|
||||
patchSet.getRefName()),
|
||||
new ReceiveCommand(
|
||||
ObjectId.zeroId(),
|
||||
commit.getId(),
|
||||
refName.substring(0, refName.lastIndexOf('/') + 1) + "new"),
|
||||
refControl.getProjectControl().getProject(), refControl.getRefName(),
|
||||
commit, user);
|
||||
|
||||
|
@@ -151,7 +151,7 @@ public class ReceiveCommits {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(ReceiveCommits.class);
|
||||
|
||||
private static final Pattern NEW_PATCHSET =
|
||||
public static final Pattern NEW_PATCHSET =
|
||||
Pattern.compile("^refs/changes/(?:[0-9][0-9]/)?([1-9][0-9]*)(?:/new)?$");
|
||||
|
||||
private static final FooterKey CHANGE_ID = new FooterKey("Change-Id");
|
||||
|
@@ -24,6 +24,7 @@ import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.events.CommitReceivedEvent;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.gerrit.server.git.ReceiveCommits;
|
||||
import com.google.gerrit.server.git.ValidationError;
|
||||
import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.gerrit.server.project.RefControl;
|
||||
@@ -50,7 +51,6 @@ import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -60,9 +60,6 @@ public class CommitValidators {
|
||||
|
||||
private static final FooterKey CHANGE_ID = new FooterKey("Change-Id");
|
||||
|
||||
private static final Pattern NEW_PATCHSET = Pattern
|
||||
.compile("^refs/changes/(?:[0-9][0-9])?(/[1-9][0-9]*){1,2}(?:/new)?$");
|
||||
|
||||
private static final String GIT_HOOKS_COMMIT_MSG =
|
||||
"`git rev-parse --git-dir`/hooks/commit-msg";
|
||||
|
||||
@@ -109,7 +106,8 @@ public class CommitValidators {
|
||||
validators.add(new CommitterUploaderValidator(refControl, canonicalWebUrl));
|
||||
validators.add(new SignedOffByValidator(refControl, canonicalWebUrl));
|
||||
if (MagicBranch.isMagicBranch(receiveEvent.command.getRefName())
|
||||
|| NEW_PATCHSET.matcher(receiveEvent.command.getRefName()).matches()) {
|
||||
|| ReceiveCommits.NEW_PATCHSET.matcher(
|
||||
receiveEvent.command.getRefName()).matches()) {
|
||||
validators.add(new ChangeIdValidator(refControl, canonicalWebUrl,
|
||||
installCommitMsgHookCommand, sshInfo));
|
||||
}
|
||||
@@ -143,7 +141,8 @@ public class CommitValidators {
|
||||
validators.add(new AuthorUploaderValidator(refControl, canonicalWebUrl));
|
||||
validators.add(new SignedOffByValidator(refControl, canonicalWebUrl));
|
||||
if (MagicBranch.isMagicBranch(receiveEvent.command.getRefName())
|
||||
|| NEW_PATCHSET.matcher(receiveEvent.command.getRefName()).matches()) {
|
||||
|| ReceiveCommits.NEW_PATCHSET.matcher(
|
||||
receiveEvent.command.getRefName()).matches()) {
|
||||
validators.add(new ChangeIdValidator(refControl, canonicalWebUrl,
|
||||
installCommitMsgHookCommand, sshInfo));
|
||||
}
|
||||
|
Reference in New Issue
Block a user