Merge changes I2c4faf27,Ie5a11598
* changes: Pass only ref name into ChangeInserter, not ref control Move creation of Change instance into ChangeInserter
This commit is contained in:
@@ -21,7 +21,7 @@ import com.google.gerrit.common.data.ProjectAccess;
|
|||||||
import com.google.gerrit.reviewdb.client.Branch;
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.account.GroupBackend;
|
import com.google.gerrit.server.account.GroupBackend;
|
||||||
import com.google.gerrit.server.config.AllProjectsNameProvider;
|
import com.google.gerrit.server.config.AllProjectsNameProvider;
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
@@ -54,7 +54,6 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
|
|||||||
|
|
||||||
private final ChangeHooks hooks;
|
private final ChangeHooks hooks;
|
||||||
private final GitReferenceUpdated gitRefUpdated;
|
private final GitReferenceUpdated gitRefUpdated;
|
||||||
private final IdentifiedUser user;
|
|
||||||
private final ProjectAccessFactory.Factory projectAccessFactory;
|
private final ProjectAccessFactory.Factory projectAccessFactory;
|
||||||
private final ProjectCache projectCache;
|
private final ProjectCache projectCache;
|
||||||
|
|
||||||
@@ -67,7 +66,6 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
|
|||||||
Provider<SetParent> setParent,
|
Provider<SetParent> setParent,
|
||||||
ChangeHooks hooks,
|
ChangeHooks hooks,
|
||||||
GitReferenceUpdated gitRefUpdated,
|
GitReferenceUpdated gitRefUpdated,
|
||||||
IdentifiedUser user,
|
|
||||||
@Assisted("projectName") Project.NameKey projectName,
|
@Assisted("projectName") Project.NameKey projectName,
|
||||||
@Nullable @Assisted ObjectId base,
|
@Nullable @Assisted ObjectId base,
|
||||||
@Assisted List<AccessSection> sectionList,
|
@Assisted List<AccessSection> sectionList,
|
||||||
@@ -80,11 +78,10 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
|
|||||||
this.projectCache = projectCache;
|
this.projectCache = projectCache;
|
||||||
this.hooks = hooks;
|
this.hooks = hooks;
|
||||||
this.gitRefUpdated = gitRefUpdated;
|
this.gitRefUpdated = gitRefUpdated;
|
||||||
this.user = user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ProjectAccess updateProjectConfig(ProjectControl ctl,
|
protected ProjectAccess updateProjectConfig(CurrentUser user,
|
||||||
ProjectConfig config, MetaDataUpdate md, boolean parentProjectUpdate)
|
ProjectConfig config, MetaDataUpdate md, boolean parentProjectUpdate)
|
||||||
throws IOException, NoSuchProjectException, ConfigInvalidException {
|
throws IOException, NoSuchProjectException, ConfigInvalidException {
|
||||||
RevCommit commit = config.commit(md);
|
RevCommit commit = config.commit(md);
|
||||||
@@ -93,7 +90,7 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
|
|||||||
base, commit.getId());
|
base, commit.getId());
|
||||||
hooks.doRefUpdatedHook(
|
hooks.doRefUpdatedHook(
|
||||||
new Branch.NameKey(config.getProject().getNameKey(), RefNames.REFS_CONFIG),
|
new Branch.NameKey(config.getProject().getNameKey(), RefNames.REFS_CONFIG),
|
||||||
base, commit.getId(), user.getAccount());
|
base, commit.getId(), user.asIdentifiedUser().getAccount());
|
||||||
|
|
||||||
projectCache.evict(config.getProject());
|
projectCache.evict(config.getProject());
|
||||||
return projectAccessFactory.create(projectName).call();
|
return projectAccessFactory.create(projectName).call();
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
|||||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||||
import com.google.gerrit.httpd.rpc.Handler;
|
import com.google.gerrit.httpd.rpc.Handler;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.account.GroupBackend;
|
import com.google.gerrit.server.account.GroupBackend;
|
||||||
import com.google.gerrit.server.account.GroupBackends;
|
import com.google.gerrit.server.account.GroupBackends;
|
||||||
import com.google.gerrit.server.config.AllProjectsNameProvider;
|
import com.google.gerrit.server.config.AllProjectsNameProvider;
|
||||||
@@ -155,14 +156,14 @@ public abstract class ProjectAccessHandler<T> extends Handler<T> {
|
|||||||
md.setMessage("Modify access rules\n");
|
md.setMessage("Modify access rules\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return updateProjectConfig(projectControl, config, md,
|
return updateProjectConfig(projectControl.getUser(), config, md,
|
||||||
parentProjectUpdate);
|
parentProjectUpdate);
|
||||||
} catch (RepositoryNotFoundException notFound) {
|
} catch (RepositoryNotFoundException notFound) {
|
||||||
throw new NoSuchProjectException(projectName);
|
throw new NoSuchProjectException(projectName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract T updateProjectConfig(ProjectControl ctl,
|
protected abstract T updateProjectConfig(CurrentUser user,
|
||||||
ProjectConfig config, MetaDataUpdate md, boolean parentProjectUpdate)
|
ProjectConfig config, MetaDataUpdate md, boolean parentProjectUpdate)
|
||||||
throws IOException, NoSuchProjectException, ConfigInvalidException,
|
throws IOException, NoSuchProjectException, ConfigInvalidException,
|
||||||
OrmException;
|
OrmException;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.httpd.rpc.project;
|
package com.google.gerrit.httpd.rpc.project;
|
||||||
|
|
||||||
import com.google.gerrit.common.FooterConstants;
|
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.common.TimeUtil;
|
import com.google.gerrit.common.TimeUtil;
|
||||||
import com.google.gerrit.common.data.AccessSection;
|
import com.google.gerrit.common.data.AccessSection;
|
||||||
@@ -23,13 +22,12 @@ import com.google.gerrit.common.data.PermissionRule;
|
|||||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.Sequences;
|
import com.google.gerrit.server.Sequences;
|
||||||
import com.google.gerrit.server.account.GroupBackend;
|
import com.google.gerrit.server.account.GroupBackend;
|
||||||
import com.google.gerrit.server.change.ChangeInserter;
|
import com.google.gerrit.server.change.ChangeInserter;
|
||||||
@@ -71,7 +69,6 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
|
|||||||
|
|
||||||
private final ReviewDb db;
|
private final ReviewDb db;
|
||||||
private final Sequences seq;
|
private final Sequences seq;
|
||||||
private final IdentifiedUser user;
|
|
||||||
private final Provider<PostReviewers> reviewersProvider;
|
private final Provider<PostReviewers> reviewersProvider;
|
||||||
private final ProjectCache projectCache;
|
private final ProjectCache projectCache;
|
||||||
private final ChangesCollection changes;
|
private final ChangesCollection changes;
|
||||||
@@ -82,7 +79,6 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
|
|||||||
ReviewProjectAccess(final ProjectControl.Factory projectControlFactory,
|
ReviewProjectAccess(final ProjectControl.Factory projectControlFactory,
|
||||||
GroupBackend groupBackend,
|
GroupBackend groupBackend,
|
||||||
MetaDataUpdate.User metaDataUpdateFactory, ReviewDb db,
|
MetaDataUpdate.User metaDataUpdateFactory, ReviewDb db,
|
||||||
IdentifiedUser user,
|
|
||||||
Provider<PostReviewers> reviewersProvider,
|
Provider<PostReviewers> reviewersProvider,
|
||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
AllProjectsNameProvider allProjects,
|
AllProjectsNameProvider allProjects,
|
||||||
@@ -102,7 +98,6 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
|
|||||||
parentProjectName, message, false);
|
parentProjectName, message, false);
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.seq = seq;
|
this.seq = seq;
|
||||||
this.user = user;
|
|
||||||
this.reviewersProvider = reviewersProvider;
|
this.reviewersProvider = reviewersProvider;
|
||||||
this.projectCache = projectCache;
|
this.projectCache = projectCache;
|
||||||
this.changes = changes;
|
this.changes = changes;
|
||||||
@@ -111,7 +106,7 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Change.Id updateProjectConfig(ProjectControl ctl,
|
protected Change.Id updateProjectConfig(CurrentUser user,
|
||||||
ProjectConfig config, MetaDataUpdate md, boolean parentProjectUpdate)
|
ProjectConfig config, MetaDataUpdate md, boolean parentProjectUpdate)
|
||||||
throws IOException, OrmException {
|
throws IOException, OrmException {
|
||||||
md.setInsertChangeId(true);
|
md.setInsertChangeId(true);
|
||||||
@@ -123,23 +118,14 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Change change = new Change(
|
|
||||||
getChangeId(commit),
|
|
||||||
changeId,
|
|
||||||
user.getAccountId(),
|
|
||||||
new Branch.NameKey(
|
|
||||||
config.getProject().getNameKey(),
|
|
||||||
RefNames.REFS_CONFIG),
|
|
||||||
TimeUtil.nowTs());
|
|
||||||
try (RevWalk rw = new RevWalk(md.getRepository());
|
try (RevWalk rw = new RevWalk(md.getRepository());
|
||||||
ObjectInserter objInserter = md.getRepository().newObjectInserter();
|
ObjectInserter objInserter = md.getRepository().newObjectInserter();
|
||||||
BatchUpdate bu = updateFactory.create(
|
BatchUpdate bu = updateFactory.create(
|
||||||
db, change.getProject(), ctl.getUser(),
|
db, config.getProject().getNameKey(), user,
|
||||||
change.getCreatedOn())) {
|
TimeUtil.nowTs())) {
|
||||||
bu.setRepository(md.getRepository(), rw, objInserter);
|
bu.setRepository(md.getRepository(), rw, objInserter);
|
||||||
bu.insertChange(
|
bu.insertChange(
|
||||||
changeInserterFactory.create(
|
changeInserterFactory.create(changeId, commit, RefNames.REFS_CONFIG)
|
||||||
ctl.controlForRef(change.getDest().get()), change, commit)
|
|
||||||
.setValidatePolicy(CommitValidators.Policy.NONE)
|
.setValidatePolicy(CommitValidators.Policy.NONE)
|
||||||
.setUpdateRef(false)); // Created by commitToNewRef.
|
.setUpdateRef(false)); // Created by commitToNewRef.
|
||||||
bu.execute();
|
bu.execute();
|
||||||
@@ -160,14 +146,6 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
|
|||||||
return changeId;
|
return changeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Change.Key getChangeId(RevCommit commit) {
|
|
||||||
List<String> idList = commit.getFooterLines(FooterConstants.CHANGE_ID);
|
|
||||||
Change.Key changeKey = !idList.isEmpty()
|
|
||||||
? new Change.Key(idList.get(idList.size() - 1).trim())
|
|
||||||
: new Change.Key("I" + commit.name());
|
|
||||||
return changeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addProjectOwnersAsReviewers(ChangeResource rsrc) {
|
private void addProjectOwnersAsReviewers(ChangeResource rsrc) {
|
||||||
final String projectOwners =
|
final String projectOwners =
|
||||||
groupBackend.get(SystemGroupBackend.PROJECT_OWNERS).getName();
|
groupBackend.get(SystemGroupBackend.PROJECT_OWNERS).getName();
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import com.google.gerrit.server.mail.RevertedSender;
|
|||||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||||
import com.google.gerrit.server.project.ChangeControl;
|
import com.google.gerrit.server.project.ChangeControl;
|
||||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||||
import com.google.gerrit.server.project.RefControl;
|
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||||
import com.google.gerrit.server.util.IdGenerator;
|
import com.google.gerrit.server.util.IdGenerator;
|
||||||
@@ -203,12 +202,12 @@ public class ChangeUtil {
|
|||||||
throws NoSuchChangeException, OrmException,
|
throws NoSuchChangeException, OrmException,
|
||||||
MissingObjectException, IncorrectObjectTypeException, IOException,
|
MissingObjectException, IncorrectObjectTypeException, IOException,
|
||||||
RestApiException, UpdateException {
|
RestApiException, UpdateException {
|
||||||
Change.Id changeId = patchSetId.getParentKey();
|
Change.Id changeIdToRevert = patchSetId.getParentKey();
|
||||||
PatchSet patch = db.get().patchSets().get(patchSetId);
|
PatchSet patch = db.get().patchSets().get(patchSetId);
|
||||||
if (patch == null) {
|
if (patch == null) {
|
||||||
throw new NoSuchChangeException(changeId);
|
throw new NoSuchChangeException(changeIdToRevert);
|
||||||
}
|
}
|
||||||
Change changeToRevert = db.get().changes().get(changeId);
|
Change changeToRevert = db.get().changes().get(changeIdToRevert);
|
||||||
|
|
||||||
Project.NameKey project = ctl.getChange().getProject();
|
Project.NameKey project = ctl.getChange().getProject();
|
||||||
try (Repository git = gitManager.openRepository(project);
|
try (Repository git = gitManager.openRepository(project);
|
||||||
@@ -246,22 +245,16 @@ public class ChangeUtil {
|
|||||||
|
|
||||||
RevCommit revertCommit;
|
RevCommit revertCommit;
|
||||||
ChangeInserter ins;
|
ChangeInserter ins;
|
||||||
|
Change.Id changeId = new Change.Id(seq.nextChangeId());
|
||||||
try (ObjectInserter oi = git.newObjectInserter()) {
|
try (ObjectInserter oi = git.newObjectInserter()) {
|
||||||
ObjectId id = oi.insert(revertCommitBuilder);
|
ObjectId id = oi.insert(revertCommitBuilder);
|
||||||
oi.flush();
|
oi.flush();
|
||||||
revertCommit = revWalk.parseCommit(id);
|
revertCommit = revWalk.parseCommit(id);
|
||||||
|
|
||||||
RefControl refControl = ctl.getRefControl();
|
|
||||||
Change change = new Change(
|
|
||||||
new Change.Key("I" + computedChangeId.name()),
|
|
||||||
new Change.Id(seq.nextChangeId()),
|
|
||||||
user.get().getAccountId(),
|
|
||||||
changeToRevert.getDest(),
|
|
||||||
TimeUtil.nowTs());
|
|
||||||
change.setTopic(changeToRevert.getTopic());
|
|
||||||
ins = changeInserterFactory.create(
|
ins = changeInserterFactory.create(
|
||||||
refControl, change, revertCommit)
|
changeId, revertCommit, ctl.getChange().getDest().get())
|
||||||
.setValidatePolicy(CommitValidators.Policy.GERRIT);
|
.setValidatePolicy(CommitValidators.Policy.GERRIT)
|
||||||
|
.setTopic(changeToRevert.getTopic());
|
||||||
|
|
||||||
ChangeMessage changeMessage = new ChangeMessage(
|
ChangeMessage changeMessage = new ChangeMessage(
|
||||||
new ChangeMessage.Key(
|
new ChangeMessage.Key(
|
||||||
@@ -271,7 +264,7 @@ public class ChangeUtil {
|
|||||||
msgBuf.append("Patch Set ").append(patchSetId.get()).append(": Reverted");
|
msgBuf.append("Patch Set ").append(patchSetId.get()).append(": Reverted");
|
||||||
msgBuf.append("\n\n");
|
msgBuf.append("\n\n");
|
||||||
msgBuf.append("This patchset was reverted in change: ")
|
msgBuf.append("This patchset was reverted in change: ")
|
||||||
.append(change.getKey().get());
|
.append("I").append(computedChangeId.name());
|
||||||
changeMessage.setMessage(msgBuf.toString());
|
changeMessage.setMessage(msgBuf.toString());
|
||||||
ChangeUpdate update = changeUpdateFactory.create(ctl, TimeUtil.nowTs());
|
ChangeUpdate update = changeUpdateFactory.create(ctl, TimeUtil.nowTs());
|
||||||
changeMessagesUtil.addChangeMessage(db.get(), update, changeMessage);
|
changeMessagesUtil.addChangeMessage(db.get(), update, changeMessage);
|
||||||
@@ -279,27 +272,26 @@ public class ChangeUtil {
|
|||||||
|
|
||||||
ins.setMessage("Uploaded patch set 1.");
|
ins.setMessage("Uploaded patch set 1.");
|
||||||
try (BatchUpdate bu = updateFactory.create(
|
try (BatchUpdate bu = updateFactory.create(
|
||||||
db.get(), change.getProject(), refControl.getUser(),
|
db.get(), project, ctl.getUser(),
|
||||||
change.getCreatedOn())) {
|
TimeUtil.nowTs())) {
|
||||||
bu.setRepository(git, revWalk, oi);
|
bu.setRepository(git, revWalk, oi);
|
||||||
bu.insertChange(ins);
|
bu.insertChange(ins);
|
||||||
bu.execute();
|
bu.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Change.Id id = ins.getChange().getId();
|
|
||||||
try {
|
try {
|
||||||
RevertedSender cm = revertedSenderFactory.create(id);
|
RevertedSender cm = revertedSenderFactory.create(changeId);
|
||||||
cm.setFrom(user.get().getAccountId());
|
cm.setFrom(user.get().getAccountId());
|
||||||
cm.setChangeMessage(ins.getChangeMessage());
|
cm.setChangeMessage(ins.getChangeMessage());
|
||||||
cm.send();
|
cm.send();
|
||||||
} catch (Exception err) {
|
} catch (Exception err) {
|
||||||
log.error("Cannot send email for revert change " + id, err);
|
log.error("Cannot send email for revert change " + changeId, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return changeId;
|
||||||
} catch (RepositoryNotFoundException e) {
|
} catch (RepositoryNotFoundException e) {
|
||||||
throw new NoSuchChangeException(changeId, e);
|
throw new NoSuchChangeException(changeIdToRevert, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,17 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.reviewdb.client.Change.INITIAL_PATCH_SET_ID;
|
import static com.google.gerrit.reviewdb.client.Change.INITIAL_PATCH_SET_ID;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.gerrit.common.ChangeHooks;
|
import com.google.gerrit.common.ChangeHooks;
|
||||||
|
import com.google.gerrit.common.FooterConstants;
|
||||||
import com.google.gerrit.common.data.LabelTypes;
|
import com.google.gerrit.common.data.LabelTypes;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
@@ -32,7 +34,6 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
|||||||
import com.google.gerrit.server.ApprovalsUtil;
|
import com.google.gerrit.server.ApprovalsUtil;
|
||||||
import com.google.gerrit.server.ChangeMessagesUtil;
|
import com.google.gerrit.server.ChangeMessagesUtil;
|
||||||
import com.google.gerrit.server.ChangeUtil;
|
import com.google.gerrit.server.ChangeUtil;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
|
||||||
import com.google.gerrit.server.events.CommitReceivedEvent;
|
import com.google.gerrit.server.events.CommitReceivedEvent;
|
||||||
import com.google.gerrit.server.git.BanCommit;
|
import com.google.gerrit.server.git.BanCommit;
|
||||||
import com.google.gerrit.server.git.BatchUpdate;
|
import com.google.gerrit.server.git.BatchUpdate;
|
||||||
@@ -47,6 +48,8 @@ import com.google.gerrit.server.mail.CreateChangeSender;
|
|||||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||||
import com.google.gerrit.server.project.ChangeControl;
|
import com.google.gerrit.server.project.ChangeControl;
|
||||||
|
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||||
|
import com.google.gerrit.server.project.ProjectControl;
|
||||||
import com.google.gerrit.server.project.RefControl;
|
import com.google.gerrit.server.project.RefControl;
|
||||||
import com.google.gerrit.server.ssh.NoSshInfo;
|
import com.google.gerrit.server.ssh.NoSshInfo;
|
||||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||||
@@ -58,22 +61,25 @@ import org.eclipse.jgit.lib.ObjectId;
|
|||||||
import org.eclipse.jgit.notes.NoteMap;
|
import org.eclipse.jgit.notes.NoteMap;
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||||
|
import org.eclipse.jgit.util.ChangeIdUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
||||||
public static interface Factory {
|
public static interface Factory {
|
||||||
ChangeInserter create(RefControl ctl, Change c, RevCommit rc);
|
ChangeInserter create(Change.Id cid, RevCommit rc, String refName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger log =
|
private static final Logger log =
|
||||||
LoggerFactory.getLogger(ChangeInserter.class);
|
LoggerFactory.getLogger(ChangeInserter.class);
|
||||||
|
|
||||||
|
private final ProjectControl.GenericFactory projectControlFactory;
|
||||||
private final PatchSetInfoFactory patchSetInfoFactory;
|
private final PatchSetInfoFactory patchSetInfoFactory;
|
||||||
private final ChangeHooks hooks;
|
private final ChangeHooks hooks;
|
||||||
private final ApprovalsUtil approvalsUtil;
|
private final ApprovalsUtil approvalsUtil;
|
||||||
@@ -82,12 +88,14 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
private final WorkQueue workQueue;
|
private final WorkQueue workQueue;
|
||||||
private final CommitValidators.Factory commitValidatorsFactory;
|
private final CommitValidators.Factory commitValidatorsFactory;
|
||||||
|
|
||||||
private final RefControl refControl;
|
|
||||||
private final IdentifiedUser user;
|
|
||||||
private final PatchSet patchSet;
|
private final PatchSet patchSet;
|
||||||
|
private final Change.Id changeId;
|
||||||
private final RevCommit commit;
|
private final RevCommit commit;
|
||||||
|
private final String refName;
|
||||||
|
|
||||||
// Fields exposed as setters.
|
// Fields exposed as setters.
|
||||||
|
private Change.Status status;
|
||||||
|
private String topic;
|
||||||
private String message;
|
private String message;
|
||||||
private CommitValidators.Policy validatePolicy =
|
private CommitValidators.Policy validatePolicy =
|
||||||
CommitValidators.Policy.GERRIT;
|
CommitValidators.Policy.GERRIT;
|
||||||
@@ -105,23 +113,18 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
private PatchSetInfo patchSetInfo;
|
private PatchSetInfo patchSetInfo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ChangeInserter(PatchSetInfoFactory patchSetInfoFactory,
|
ChangeInserter(ProjectControl.GenericFactory projectControlFactory,
|
||||||
|
PatchSetInfoFactory patchSetInfoFactory,
|
||||||
ChangeHooks hooks,
|
ChangeHooks hooks,
|
||||||
ApprovalsUtil approvalsUtil,
|
ApprovalsUtil approvalsUtil,
|
||||||
ChangeMessagesUtil cmUtil,
|
ChangeMessagesUtil cmUtil,
|
||||||
CreateChangeSender.Factory createChangeSenderFactory,
|
CreateChangeSender.Factory createChangeSenderFactory,
|
||||||
WorkQueue workQueue,
|
WorkQueue workQueue,
|
||||||
CommitValidators.Factory commitValidatorsFactory,
|
CommitValidators.Factory commitValidatorsFactory,
|
||||||
@Assisted RefControl refControl,
|
@Assisted Change.Id changeId,
|
||||||
@Assisted Change change,
|
@Assisted RevCommit commit,
|
||||||
@Assisted RevCommit commit) {
|
@Assisted String refName) {
|
||||||
String projectName = refControl.getProjectControl().getProject().getName();
|
this.projectControlFactory = projectControlFactory;
|
||||||
String refName = refControl.getRefName();
|
|
||||||
checkArgument(projectName.equals(change.getProject().get())
|
|
||||||
&& refName.equals(change.getDest().get()),
|
|
||||||
"RefControl for %s,%s does not match change destination %s",
|
|
||||||
projectName, refName, change.getDest());
|
|
||||||
|
|
||||||
this.patchSetInfoFactory = patchSetInfoFactory;
|
this.patchSetInfoFactory = patchSetInfoFactory;
|
||||||
this.hooks = hooks;
|
this.hooks = hooks;
|
||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
@@ -130,9 +133,9 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
this.workQueue = workQueue;
|
this.workQueue = workQueue;
|
||||||
this.commitValidatorsFactory = commitValidatorsFactory;
|
this.commitValidatorsFactory = commitValidatorsFactory;
|
||||||
|
|
||||||
this.refControl = refControl;
|
this.changeId = changeId;
|
||||||
this.change = change;
|
|
||||||
this.commit = commit;
|
this.commit = commit;
|
||||||
|
this.refName = refName;
|
||||||
this.reviewers = Collections.emptySet();
|
this.reviewers = Collections.emptySet();
|
||||||
this.extraCC = Collections.emptySet();
|
this.extraCC = Collections.emptySet();
|
||||||
this.approvals = Collections.emptyMap();
|
this.approvals = Collections.emptyMap();
|
||||||
@@ -140,21 +143,49 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
this.sendMail = true;
|
this.sendMail = true;
|
||||||
this.updateRef = true;
|
this.updateRef = true;
|
||||||
|
|
||||||
user = refControl.getUser().asIdentifiedUser();
|
|
||||||
patchSet =
|
patchSet =
|
||||||
new PatchSet(new PatchSet.Id(change.getId(), INITIAL_PATCH_SET_ID));
|
new PatchSet(new PatchSet.Id(changeId, INITIAL_PATCH_SET_ID));
|
||||||
patchSet.setCreatedOn(change.getCreatedOn());
|
|
||||||
patchSet.setUploader(change.getOwner());
|
|
||||||
patchSet.setRevision(new RevId(commit.name()));
|
patchSet.setRevision(new RevId(commit.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Change getChange() {
|
public Change createChange(Context ctx) throws IOException {
|
||||||
|
change = new Change(
|
||||||
|
getChangeKey(commit),
|
||||||
|
changeId,
|
||||||
|
ctx.getUser().getAccountId(),
|
||||||
|
new Branch.NameKey(ctx.getProject(), refName),
|
||||||
|
ctx.getWhen());
|
||||||
|
change.setStatus(MoreObjects.firstNonNull(status, Change.Status.NEW));
|
||||||
|
change.setTopic(topic);
|
||||||
|
patchSet.setCreatedOn(ctx.getWhen());
|
||||||
|
patchSet.setUploader(ctx.getUser().getAccountId());
|
||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IdentifiedUser getUser() {
|
private static Change.Key getChangeKey(RevCommit commit) throws IOException {
|
||||||
return user;
|
List<String> idList = commit.getFooterLines(FooterConstants.CHANGE_ID);
|
||||||
|
if (!idList.isEmpty()) {
|
||||||
|
return new Change.Key(idList.get(idList.size() - 1).trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectId id = ChangeIdUtil.computeChangeId(commit.getTree(), commit,
|
||||||
|
commit.getAuthorIdent(), commit.getCommitterIdent(),
|
||||||
|
commit.getShortMessage());
|
||||||
|
StringBuilder changeId = new StringBuilder();
|
||||||
|
changeId.append("I").append(ObjectId.toString(id));
|
||||||
|
return new Change.Key(changeId.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change getChange() {
|
||||||
|
checkState(change != null, "getChange() only valid after creating change");
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeInserter setTopic(String topic) {
|
||||||
|
checkState(change == null, "setTopic(String) only valid before creating change");
|
||||||
|
this.topic = topic;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInserter setMessage(String message) {
|
public ChangeInserter setMessage(String message) {
|
||||||
@@ -178,8 +209,18 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInserter setDraft(boolean draft) {
|
public ChangeInserter setDraft(boolean draft) {
|
||||||
change.setStatus(draft ? Change.Status.DRAFT : Change.Status.NEW);
|
checkState(change == null,
|
||||||
patchSet.setDraft(draft);
|
"setDraft(boolean) only valid before creating change");
|
||||||
|
return setStatus(draft ? Change.Status.DRAFT : Change.Status.NEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeInserter setStatus(Change.Status status) {
|
||||||
|
checkState(change == null,
|
||||||
|
"setStatus(Change.Status) only valid before creating change");
|
||||||
|
this.status = status;
|
||||||
|
if (Change.Status.DRAFT.equals(status)) {
|
||||||
|
patchSet.setDraft(true);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,14 +286,15 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
patchSetInfo = patchSetInfoFactory.get(
|
patchSetInfo = patchSetInfoFactory.get(
|
||||||
ctx.getRevWalk(), commit, patchSet.getId());
|
ctx.getRevWalk(), commit, patchSet.getId());
|
||||||
ctx.getChange().setCurrentPatchSet(patchSetInfo);
|
ctx.getChange().setCurrentPatchSet(patchSetInfo);
|
||||||
|
|
||||||
ChangeUpdate update = ctx.getUpdate(patchSet.getId());
|
ChangeUpdate update = ctx.getUpdate(patchSet.getId());
|
||||||
|
update.setTopic(change.getTopic());
|
||||||
|
|
||||||
if (patchSet.getGroups() == null) {
|
if (patchSet.getGroups() == null) {
|
||||||
patchSet.setGroups(GroupCollector.getDefaultGroups(patchSet));
|
patchSet.setGroups(GroupCollector.getDefaultGroups(patchSet));
|
||||||
}
|
}
|
||||||
db.patchSets().insert(Collections.singleton(patchSet));
|
db.patchSets().insert(Collections.singleton(patchSet));
|
||||||
ctx.saveChange();
|
ctx.saveChange();
|
||||||
update.setTopic(change.getTopic());
|
|
||||||
|
|
||||||
/* TODO: fixStatus is used here because the tests
|
/* TODO: fixStatus is used here because the tests
|
||||||
* (byStatusClosed() in AbstractQueryChangesTest)
|
* (byStatusClosed() in AbstractQueryChangesTest)
|
||||||
@@ -272,7 +314,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
if (message != null) {
|
if (message != null) {
|
||||||
changeMessage =
|
changeMessage =
|
||||||
new ChangeMessage(new ChangeMessage.Key(change.getId(),
|
new ChangeMessage(new ChangeMessage.Key(change.getId(),
|
||||||
ChangeUtil.messageUUID(db)), user.getAccountId(),
|
ChangeUtil.messageUUID(db)), ctx.getUser().getAccountId(),
|
||||||
patchSet.getCreatedOn(), patchSet.getId());
|
patchSet.getCreatedOn(), patchSet.getId());
|
||||||
changeMessage.setMessage(message);
|
changeMessage.setMessage(message);
|
||||||
cmUtil.addChangeMessage(db, update, changeMessage);
|
cmUtil.addChangeMessage(db, update, changeMessage);
|
||||||
@@ -314,8 +356,9 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
ReviewDb db = ctx.getDb();
|
ReviewDb db = ctx.getDb();
|
||||||
hooks.doPatchsetCreatedHook(change, patchSet, db);
|
hooks.doPatchsetCreatedHook(change, patchSet, db);
|
||||||
if (approvals != null && !approvals.isEmpty()) {
|
if (approvals != null && !approvals.isEmpty()) {
|
||||||
hooks.doCommentAddedHook(
|
hooks.doCommentAddedHook(change,
|
||||||
change, user.getAccount(), patchSet, null, approvals, db);
|
ctx.getUser().asIdentifiedUser().getAccount(), patchSet, null,
|
||||||
|
approvals, db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,21 +368,24 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
if (validatePolicy == CommitValidators.Policy.NONE) {
|
if (validatePolicy == CommitValidators.Policy.NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CommitValidators cv = commitValidatorsFactory.create(
|
|
||||||
refControl, new NoSshInfo(), ctx.getRepository());
|
|
||||||
|
|
||||||
String refName = patchSet.getId().toRefName();
|
|
||||||
CommitReceivedEvent event = new CommitReceivedEvent(
|
|
||||||
new ReceiveCommand(
|
|
||||||
ObjectId.zeroId(),
|
|
||||||
commit.getId(),
|
|
||||||
refName),
|
|
||||||
refControl.getProjectControl().getProject(),
|
|
||||||
change.getDest().get(),
|
|
||||||
commit,
|
|
||||||
user);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
RefControl refControl = projectControlFactory
|
||||||
|
.controlFor(ctx.getProject(), ctx.getUser()).controlForRef(refName);
|
||||||
|
CommitValidators cv = commitValidatorsFactory.create(
|
||||||
|
refControl, new NoSshInfo(), ctx.getRepository());
|
||||||
|
|
||||||
|
String refName = patchSet.getId().toRefName();
|
||||||
|
CommitReceivedEvent event = new CommitReceivedEvent(
|
||||||
|
new ReceiveCommand(
|
||||||
|
ObjectId.zeroId(),
|
||||||
|
commit.getId(),
|
||||||
|
refName),
|
||||||
|
refControl.getProjectControl().getProject(),
|
||||||
|
change.getDest().get(),
|
||||||
|
commit,
|
||||||
|
ctx.getUser().asIdentifiedUser());
|
||||||
|
|
||||||
switch (validatePolicy) {
|
switch (validatePolicy) {
|
||||||
case RECEIVE_COMMITS:
|
case RECEIVE_COMMITS:
|
||||||
NoteMap rejectCommits = BanCommit.loadRejectCommitsMap(
|
NoteMap rejectCommits = BanCommit.loadRejectCommitsMap(
|
||||||
@@ -354,6 +400,8 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
}
|
}
|
||||||
} catch (CommitValidationException e) {
|
} catch (CommitValidationException e) {
|
||||||
throw new ResourceConflictException(e.getFullMessage());
|
throw new ResourceConflictException(e.getFullMessage());
|
||||||
|
} catch (NoSuchProjectException e) {
|
||||||
|
throw new ResourceConflictException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,14 +189,15 @@ public class CherryPickChange {
|
|||||||
if (!Strings.isNullOrEmpty(change.getTopic())) {
|
if (!Strings.isNullOrEmpty(change.getTopic())) {
|
||||||
newTopic = change.getTopic() + "-" + newDest.getShortName();
|
newTopic = change.getTopic() + "-" + newDest.getShortName();
|
||||||
}
|
}
|
||||||
Change newChange = createNewChange(git, revWalk, oi, changeKey,
|
Change.Id newChangeId =
|
||||||
project, destRef, cherryPickCommit, refControl, identifiedUser,
|
createNewChange(git, revWalk, oi, project, cherryPickCommit,
|
||||||
newTopic, change.getDest());
|
refControl.getRefName(), identifiedUser, newTopic,
|
||||||
|
change.getDest());
|
||||||
|
|
||||||
addMessageToSourceChange(change, patch.getId(), destinationBranch,
|
addMessageToSourceChange(change, patch.getId(), destinationBranch,
|
||||||
cherryPickCommit, identifiedUser, refControl);
|
cherryPickCommit, identifiedUser, refControl);
|
||||||
|
|
||||||
return newChange.getId();
|
return newChangeId;
|
||||||
}
|
}
|
||||||
} catch (MergeIdenticalTreeException | MergeConflictException e) {
|
} catch (MergeIdenticalTreeException | MergeConflictException e) {
|
||||||
throw new IntegrationException("Cherry pick failed: " + e.getMessage());
|
throw new IntegrationException("Cherry pick failed: " + e.getMessage());
|
||||||
@@ -231,29 +232,26 @@ public class CherryPickChange {
|
|||||||
return change.getId();
|
return change.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Change createNewChange(Repository git, RevWalk revWalk,
|
private Change.Id createNewChange(Repository git, RevWalk revWalk,
|
||||||
ObjectInserter oi, Change.Key changeKey, Project.NameKey project,
|
ObjectInserter oi, Project.NameKey project,
|
||||||
Ref destRef, CodeReviewCommit cherryPickCommit, RefControl refControl,
|
CodeReviewCommit cherryPickCommit, String refName,
|
||||||
IdentifiedUser identifiedUser, String topic, Branch.NameKey sourceBranch)
|
IdentifiedUser identifiedUser, String topic, Branch.NameKey sourceBranch)
|
||||||
throws RestApiException, UpdateException, OrmException {
|
throws RestApiException, UpdateException, OrmException, IOException {
|
||||||
Change change =
|
Change.Id changeId = new Change.Id(seq.nextChangeId());
|
||||||
new Change(changeKey, new Change.Id(seq.nextChangeId()),
|
|
||||||
identifiedUser.getAccountId(), new Branch.NameKey(project,
|
|
||||||
destRef.getName()), TimeUtil.nowTs());
|
|
||||||
change.setTopic(topic);
|
|
||||||
ChangeInserter ins = changeInserterFactory.create(
|
ChangeInserter ins = changeInserterFactory.create(
|
||||||
refControl, change, cherryPickCommit)
|
changeId, cherryPickCommit, refName)
|
||||||
.setValidatePolicy(CommitValidators.Policy.GERRIT);
|
.setValidatePolicy(CommitValidators.Policy.GERRIT)
|
||||||
|
.setTopic(topic);
|
||||||
|
|
||||||
ins.setMessage(
|
ins.setMessage(
|
||||||
messageForDestinationChange(ins.getPatchSet().getId(), sourceBranch));
|
messageForDestinationChange(ins.getPatchSet().getId(), sourceBranch));
|
||||||
try (BatchUpdate bu = batchUpdateFactory.create(
|
try (BatchUpdate bu = batchUpdateFactory.create(
|
||||||
db.get(), change.getProject(), identifiedUser, TimeUtil.nowTs())) {
|
db.get(), project, identifiedUser, TimeUtil.nowTs())) {
|
||||||
bu.setRepository(git, revWalk, oi);
|
bu.setRepository(git, revWalk, oi);
|
||||||
bu.insertChange(ins);
|
bu.insertChange(ins);
|
||||||
bu.execute();
|
bu.execute();
|
||||||
}
|
}
|
||||||
return ins.getChange();
|
return changeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMessageToSourceChange(Change change, PatchSet.Id patchSetId,
|
private void addMessageToSourceChange(Change change, PatchSet.Id patchSetId,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package com.google.gerrit.server.change;
|
|||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.gerrit.common.FooterConstants;
|
|
||||||
import com.google.gerrit.common.TimeUtil;
|
import com.google.gerrit.common.TimeUtil;
|
||||||
import com.google.gerrit.common.data.Capable;
|
import com.google.gerrit.common.data.Capable;
|
||||||
import com.google.gerrit.extensions.client.ChangeStatus;
|
import com.google.gerrit.extensions.client.ChangeStatus;
|
||||||
@@ -29,7 +28,6 @@ import com.google.gerrit.extensions.restapi.RestApiException;
|
|||||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
@@ -196,15 +194,8 @@ public class CreateChange implements
|
|||||||
try (ObjectInserter oi = git.newObjectInserter()) {
|
try (ObjectInserter oi = git.newObjectInserter()) {
|
||||||
RevCommit c = newCommit(oi, rw, author, mergeTip, commitMessage);
|
RevCommit c = newCommit(oi, rw, author, mergeTip, commitMessage);
|
||||||
|
|
||||||
Change change = new Change(
|
Change.Id changeId = new Change.Id(seq.nextChangeId());
|
||||||
getChangeId(id, c),
|
ChangeInserter ins = changeInserterFactory.create(changeId, c, refName)
|
||||||
new Change.Id(seq.nextChangeId()),
|
|
||||||
me.getAccountId(),
|
|
||||||
new Branch.NameKey(project, refName),
|
|
||||||
now);
|
|
||||||
|
|
||||||
ChangeInserter ins = changeInserterFactory
|
|
||||||
.create(refControl, change, c)
|
|
||||||
.setValidatePolicy(CommitValidators.Policy.GERRIT);
|
.setValidatePolicy(CommitValidators.Policy.GERRIT);
|
||||||
ins.setMessage(String.format("Uploaded patch set %s.",
|
ins.setMessage(String.format("Uploaded patch set %s.",
|
||||||
ins.getPatchSet().getPatchSetId()));
|
ins.getPatchSet().getPatchSetId()));
|
||||||
@@ -212,31 +203,22 @@ public class CreateChange implements
|
|||||||
if (topic != null) {
|
if (topic != null) {
|
||||||
topic = Strings.emptyToNull(topic.trim());
|
topic = Strings.emptyToNull(topic.trim());
|
||||||
}
|
}
|
||||||
change.setTopic(topic);
|
ins.setTopic(topic);
|
||||||
ins.setDraft(input.status != null && input.status == ChangeStatus.DRAFT);
|
ins.setDraft(input.status != null && input.status == ChangeStatus.DRAFT);
|
||||||
ins.setGroups(groups);
|
ins.setGroups(groups);
|
||||||
try (BatchUpdate bu = updateFactory.create(
|
try (BatchUpdate bu = updateFactory.create(
|
||||||
db.get(), change.getProject(), me, now)) {
|
db.get(), project, me, now)) {
|
||||||
bu.setRepository(git, rw, oi);
|
bu.setRepository(git, rw, oi);
|
||||||
bu.insertChange(ins);
|
bu.insertChange(ins);
|
||||||
bu.execute();
|
bu.execute();
|
||||||
}
|
}
|
||||||
ChangeJson json = jsonFactory.create(ChangeJson.NO_OPTIONS);
|
ChangeJson json = jsonFactory.create(ChangeJson.NO_OPTIONS);
|
||||||
return Response.created(json.format(change.getId()));
|
return Response.created(json.format(changeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Change.Key getChangeId(ObjectId id, RevCommit emptyCommit) {
|
|
||||||
List<String> idList = emptyCommit.getFooterLines(
|
|
||||||
FooterConstants.CHANGE_ID);
|
|
||||||
Change.Key changeKey = !idList.isEmpty()
|
|
||||||
? new Change.Key(idList.get(idList.size() - 1).trim())
|
|
||||||
: new Change.Key("I" + id.name());
|
|
||||||
return changeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static RevCommit newCommit(ObjectInserter oi, RevWalk rw,
|
private static RevCommit newCommit(ObjectInserter oi, RevWalk rw,
|
||||||
PersonIdent authorIdent, RevCommit mergeTip, String commitMessage)
|
PersonIdent authorIdent, RevCommit mergeTip, String commitMessage)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class InsertChangeOp extends Op {
|
public abstract static class InsertChangeOp extends Op {
|
||||||
public abstract Change getChange();
|
public abstract Change createChange(Context ctx) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ChainedReceiveCommands {
|
private static class ChainedReceiveCommands {
|
||||||
@@ -481,8 +481,9 @@ public class BatchUpdate implements AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BatchUpdate insertChange(InsertChangeOp op) {
|
public BatchUpdate insertChange(InsertChangeOp op) throws IOException {
|
||||||
Change c = op.getChange();
|
Context ctx = new Context();
|
||||||
|
Change c = op.createChange(ctx);
|
||||||
checkArgument(!newChanges.containsKey(c.getId()),
|
checkArgument(!newChanges.containsKey(c.getId()),
|
||||||
"only one op allowed to create change %s", c.getId());
|
"only one op allowed to create change %s", c.getId());
|
||||||
newChanges.put(c.getId(), c);
|
newChanges.put(c.getId(), c);
|
||||||
|
|||||||
@@ -712,7 +712,7 @@ public class ReceiveCommits {
|
|||||||
Iterables.filter(newChanges, new Predicate<CreateRequest>() {
|
Iterables.filter(newChanges, new Predicate<CreateRequest>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(CreateRequest input) {
|
public boolean apply(CreateRequest input) {
|
||||||
return input.created;
|
return input.change != null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!Iterables.isEmpty(created)) {
|
if (!Iterables.isEmpty(created)) {
|
||||||
@@ -1583,10 +1583,9 @@ public class ReceiveCommits {
|
|||||||
+ "to override please set the base manually");
|
+ "to override please set the base manually");
|
||||||
}
|
}
|
||||||
|
|
||||||
Change.Key changeKey = new Change.Key("I" + c.name());
|
|
||||||
final List<String> idList = c.getFooterLines(CHANGE_ID);
|
final List<String> idList = c.getFooterLines(CHANGE_ID);
|
||||||
if (idList.isEmpty()) {
|
if (idList.isEmpty()) {
|
||||||
newChanges.add(new CreateRequest(magicBranch.ctl, c, changeKey));
|
newChanges.add(new CreateRequest(c, magicBranch.dest.get()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1598,8 +1597,7 @@ public class ReceiveCommits {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeKey = new Change.Key(idStr);
|
pending.add(new ChangeLookup(c, new Change.Key(idStr)));
|
||||||
pending.add(new ChangeLookup(c, changeKey));
|
|
||||||
if (maxBatchChanges != 0
|
if (maxBatchChanges != 0
|
||||||
&& pending.size() + newChanges.size() > maxBatchChanges) {
|
&& pending.size() + newChanges.size() > maxBatchChanges) {
|
||||||
reject(magicBranch.cmd,
|
reject(magicBranch.cmd,
|
||||||
@@ -1650,7 +1648,7 @@ public class ReceiveCommits {
|
|||||||
|
|
||||||
newChangeIds.add(p.changeKey);
|
newChangeIds.add(p.changeKey);
|
||||||
}
|
}
|
||||||
newChanges.add(new CreateRequest(magicBranch.ctl, p.commit, p.changeKey));
|
newChanges.add(new CreateRequest(p.commit, magicBranch.dest.get()));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Should never happen, the core receive process would have
|
// Should never happen, the core receive process would have
|
||||||
@@ -1729,21 +1727,17 @@ public class ReceiveCommits {
|
|||||||
final RevCommit commit;
|
final RevCommit commit;
|
||||||
final ReceiveCommand cmd;
|
final ReceiveCommand cmd;
|
||||||
final ChangeInserter ins;
|
final ChangeInserter ins;
|
||||||
|
Change.Id changeId;
|
||||||
Change change;
|
Change change;
|
||||||
boolean created;
|
|
||||||
Collection<String> groups;
|
Collection<String> groups;
|
||||||
|
|
||||||
CreateRequest(RefControl ctl, RevCommit c, Change.Key changeKey)
|
CreateRequest(RevCommit c, String refName)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
commit = c;
|
commit = c;
|
||||||
change = new Change(changeKey,
|
changeId = new Change.Id(seq.nextChangeId());
|
||||||
new Change.Id(seq.nextChangeId()),
|
ins = changeInserterFactory.create(changeId, c, refName)
|
||||||
user.getAccountId(),
|
|
||||||
magicBranch.dest,
|
|
||||||
TimeUtil.nowTs());
|
|
||||||
change.setTopic(magicBranch.topic);
|
|
||||||
ins = changeInserterFactory.create(ctl, change, c)
|
|
||||||
.setDraft(magicBranch.draft)
|
.setDraft(magicBranch.draft)
|
||||||
|
.setTopic(magicBranch.topic)
|
||||||
// Changes already validated in validateNewCommits.
|
// Changes already validated in validateNewCommits.
|
||||||
.setValidatePolicy(CommitValidators.Policy.NONE);
|
.setValidatePolicy(CommitValidators.Policy.NONE);
|
||||||
cmd = new ReceiveCommand(ObjectId.zeroId(), c,
|
cmd = new ReceiveCommand(ObjectId.zeroId(), c,
|
||||||
@@ -1757,8 +1751,8 @@ public class ReceiveCommits {
|
|||||||
ListenableFuture<Void> future = changeUpdateExector.submit(
|
ListenableFuture<Void> future = changeUpdateExector.submit(
|
||||||
requestScopePropagator.wrap(new Callable<Void>() {
|
requestScopePropagator.wrap(new Callable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call()
|
public Void call() throws IOException, OrmException,
|
||||||
throws OrmException, RestApiException, UpdateException {
|
RestApiException, UpdateException {
|
||||||
if (caller == Thread.currentThread()) {
|
if (caller == Thread.currentThread()) {
|
||||||
insertChange(ReceiveCommits.this.db);
|
insertChange(ReceiveCommits.this.db);
|
||||||
} else {
|
} else {
|
||||||
@@ -1774,7 +1768,7 @@ public class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void insertChange(ReviewDb threadLocalDb)
|
private void insertChange(ReviewDb threadLocalDb)
|
||||||
throws OrmException, RestApiException, UpdateException {
|
throws IOException, OrmException, RestApiException, UpdateException {
|
||||||
final PatchSet ps = ins.setGroups(groups).getPatchSet();
|
final PatchSet ps = ins.setGroups(groups).getPatchSet();
|
||||||
final Account.Id me = user.getAccountId();
|
final Account.Id me = user.getAccountId();
|
||||||
final List<FooterLine> footerLines = commit.getFooterLines();
|
final List<FooterLine> footerLines = commit.getFooterLines();
|
||||||
@@ -1790,7 +1784,7 @@ public class ReceiveCommits {
|
|||||||
approvals, Collections.<String, PatchSetApproval> emptyMap());
|
approvals, Collections.<String, PatchSetApproval> emptyMap());
|
||||||
try (ObjectInserter oi = repo.newObjectInserter();
|
try (ObjectInserter oi = repo.newObjectInserter();
|
||||||
BatchUpdate bu = batchUpdateFactory.create(threadLocalDb,
|
BatchUpdate bu = batchUpdateFactory.create(threadLocalDb,
|
||||||
change.getProject(), user, change.getCreatedOn())) {
|
magicBranch.dest.getParentKey(), user, TimeUtil.nowTs())) {
|
||||||
bu.setRepository(repo, rp.getRevWalk(), oi);
|
bu.setRepository(repo, rp.getRevWalk(), oi);
|
||||||
bu.insertChange(ins
|
bu.insertChange(ins
|
||||||
.setReviewers(recipients.getReviewers())
|
.setReviewers(recipients.getReviewers())
|
||||||
@@ -1802,12 +1796,12 @@ public class ReceiveCommits {
|
|||||||
.setUpdateRef(false));
|
.setUpdateRef(false));
|
||||||
if (magicBranch != null) {
|
if (magicBranch != null) {
|
||||||
bu.addOp(
|
bu.addOp(
|
||||||
ins.getChange().getId(),
|
changeId,
|
||||||
hashtagsFactory.create(new HashtagsInput(magicBranch.hashtags))
|
hashtagsFactory.create(new HashtagsInput(magicBranch.hashtags))
|
||||||
.setRunHooks(false));
|
.setRunHooks(false));
|
||||||
if (!Strings.isNullOrEmpty(magicBranch.topic)) {
|
if (!Strings.isNullOrEmpty(magicBranch.topic)) {
|
||||||
bu.addOp(
|
bu.addOp(
|
||||||
ins.getChange().getId(),
|
changeId,
|
||||||
new BatchUpdate.Op() {
|
new BatchUpdate.Op() {
|
||||||
@Override
|
@Override
|
||||||
public void updateChange(ChangeContext ctx) throws Exception {
|
public void updateChange(ChangeContext ctx) throws Exception {
|
||||||
@@ -1818,7 +1812,6 @@ public class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
bu.execute();
|
bu.execute();
|
||||||
}
|
}
|
||||||
created = true;
|
|
||||||
change = ins.getChange();
|
change = ins.getChange();
|
||||||
|
|
||||||
if (magicBranch != null && magicBranch.submit) {
|
if (magicBranch != null && magicBranch.submit) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package com.google.gerrit.server.query.change;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.TruthJUnit.assume;
|
import static com.google.common.truth.TruthJUnit.assume;
|
||||||
import static com.google.gerrit.extensions.client.ListChangesOption.REVIEWED;
|
import static com.google.gerrit.extensions.client.ListChangesOption.REVIEWED;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
|
||||||
import static java.util.concurrent.TimeUnit.HOURS;
|
import static java.util.concurrent.TimeUnit.HOURS;
|
||||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
@@ -30,7 +29,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.hash.Hashing;
|
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.common.TimeUtil;
|
import com.google.gerrit.common.TimeUtil;
|
||||||
import com.google.gerrit.extensions.api.GerritApi;
|
import com.google.gerrit.extensions.api.GerritApi;
|
||||||
@@ -196,8 +194,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byId() throws Exception {
|
public void byId() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
assertQuery("12345");
|
assertQuery("12345");
|
||||||
assertQuery(change1.getId().get(), change1);
|
assertQuery(change1.getId().get(), change1);
|
||||||
@@ -207,7 +205,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byKey() throws Exception {
|
public void byKey() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change = insert(newChange(repo, null, null, null, null));
|
Change change = insert(repo, newChange(repo));
|
||||||
String key = change.getKey().get();
|
String key = change.getKey().get();
|
||||||
|
|
||||||
assertQuery("I0000000000000000000000000000000000000000");
|
assertQuery("I0000000000000000000000000000000000000000");
|
||||||
@@ -220,7 +218,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byTriplet() throws Exception {
|
public void byTriplet() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change = insert(newChange(repo, null, null, null, "branch"));
|
Change change = insert(repo, newChangeForBranch(repo, "branch"));
|
||||||
String k = change.getKey().get();
|
String k = change.getKey().get();
|
||||||
|
|
||||||
assertQuery("repo~branch~" + k, change);
|
assertQuery("repo~branch~" + k, change);
|
||||||
@@ -243,14 +241,10 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byStatus() throws Exception {
|
public void byStatus() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins1 = newChange(repo, null, null, null, null);
|
ChangeInserter ins1 = newChangeWithStatus(repo, Change.Status.NEW);
|
||||||
Change change1 = ins1.getChange();
|
Change change1 = insert(repo, ins1);
|
||||||
change1.setStatus(Change.Status.NEW);
|
ChangeInserter ins2 = newChangeWithStatus(repo, Change.Status.MERGED);
|
||||||
insert(ins1);
|
Change change2 = insert(repo, ins2);
|
||||||
ChangeInserter ins2 = newChange(repo, null, null, null, null);
|
|
||||||
Change change2 = ins2.getChange();
|
|
||||||
change2.setStatus(Change.Status.MERGED);
|
|
||||||
insert(ins2);
|
|
||||||
|
|
||||||
assertQuery("status:new", change1);
|
assertQuery("status:new", change1);
|
||||||
assertQuery("status:NEW", change1);
|
assertQuery("status:NEW", change1);
|
||||||
@@ -262,18 +256,11 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byStatusOpen() throws Exception {
|
public void byStatusOpen() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins1 = newChange(repo, null, null, null, null);
|
ChangeInserter ins1 = newChangeWithStatus(repo, Change.Status.NEW);
|
||||||
Change change1 = ins1.getChange();
|
Change change1 = insert(repo, ins1);
|
||||||
change1.setStatus(Change.Status.NEW);
|
ChangeInserter ins2 = newChangeWithStatus(repo, Change.Status.DRAFT);
|
||||||
insert(ins1);
|
Change change2 = insert(repo, ins2);
|
||||||
ChangeInserter ins2 = newChange(repo, null, null, null, null);
|
insert(repo, newChangeWithStatus(repo, Change.Status.MERGED));
|
||||||
Change change2 = ins2.getChange();
|
|
||||||
change2.setStatus(Change.Status.DRAFT);
|
|
||||||
insert(ins2);
|
|
||||||
ChangeInserter ins3 = newChange(repo, null, null, null, null);
|
|
||||||
Change change3 = ins3.getChange();
|
|
||||||
change3.setStatus(Change.Status.MERGED);
|
|
||||||
insert(ins3);
|
|
||||||
|
|
||||||
Change[] expected = new Change[] {change2, change1};
|
Change[] expected = new Change[] {change2, change1};
|
||||||
assertQuery("status:open", expected);
|
assertQuery("status:open", expected);
|
||||||
@@ -292,14 +279,9 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byStatusDraft() throws Exception {
|
public void byStatusDraft() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins1 = newChange(repo, null, null, null, null);
|
insert(repo, newChangeWithStatus(repo, Change.Status.NEW));
|
||||||
Change change1 = ins1.getChange();
|
ChangeInserter ins2 = newChangeWithStatus(repo, Change.Status.DRAFT);
|
||||||
change1.setStatus(Change.Status.NEW);
|
Change change2 = insert(repo, ins2);
|
||||||
insert(ins1);
|
|
||||||
ChangeInserter ins2 = newChange(repo, null, null, null, null);
|
|
||||||
Change change2 = ins2.getChange();
|
|
||||||
change2.setStatus(Change.Status.DRAFT);
|
|
||||||
insert(ins2);
|
|
||||||
|
|
||||||
Change[] expected = new Change[] {change2};
|
Change[] expected = new Change[] {change2};
|
||||||
assertQuery("status:draft", expected);
|
assertQuery("status:draft", expected);
|
||||||
@@ -314,18 +296,11 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byStatusClosed() throws Exception {
|
public void byStatusClosed() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins1 = newChange(repo, null, null, null, null);
|
ChangeInserter ins1 = newChangeWithStatus(repo, Change.Status.MERGED);
|
||||||
Change change1 = ins1.getChange();
|
Change change1 = insert(repo, ins1);
|
||||||
change1.setStatus(Change.Status.MERGED);
|
ChangeInserter ins2 = newChangeWithStatus(repo, Change.Status.ABANDONED);
|
||||||
insert(ins1);
|
Change change2 = insert(repo, ins2);
|
||||||
ChangeInserter ins2 = newChange(repo, null, null, null, null);
|
insert(repo, newChangeWithStatus(repo, Change.Status.NEW));
|
||||||
Change change2 = ins2.getChange();
|
|
||||||
change2.setStatus(Change.Status.ABANDONED);
|
|
||||||
insert(ins2);
|
|
||||||
ChangeInserter ins3 = newChange(repo, null, null, null, null);
|
|
||||||
Change change3 = ins3.getChange();
|
|
||||||
change3.setStatus(Change.Status.NEW);
|
|
||||||
insert(ins3);
|
|
||||||
|
|
||||||
Change[] expected = new Change[] {change2, change1};
|
Change[] expected = new Change[] {change2, change1};
|
||||||
assertQuery("status:closed", expected);
|
assertQuery("status:closed", expected);
|
||||||
@@ -342,14 +317,9 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byStatusPrefix() throws Exception {
|
public void byStatusPrefix() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins1 = newChange(repo, null, null, null, null);
|
ChangeInserter ins1 = newChangeWithStatus(repo, Change.Status.NEW);
|
||||||
Change change1 = ins1.getChange();
|
Change change1 = insert(repo, ins1);
|
||||||
change1.setStatus(Change.Status.NEW);
|
insert(repo, newChangeWithStatus(repo, Change.Status.MERGED));
|
||||||
insert(ins1);
|
|
||||||
ChangeInserter ins2 = newChange(repo, null, null, null, null);
|
|
||||||
Change change2 = ins2.getChange();
|
|
||||||
change2.setStatus(Change.Status.MERGED);
|
|
||||||
insert(ins2);
|
|
||||||
|
|
||||||
assertQuery("status:n", change1);
|
assertQuery("status:n", change1);
|
||||||
assertQuery("status:ne", change1);
|
assertQuery("status:ne", change1);
|
||||||
@@ -364,8 +334,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byCommit() throws Exception {
|
public void byCommit() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins = newChange(repo, null, null, null, null);
|
ChangeInserter ins = newChange(repo);
|
||||||
insert(ins);
|
insert(repo, ins);
|
||||||
String sha = ins.getPatchSet().getRevision().get();
|
String sha = ins.getPatchSet().getRevision().get();
|
||||||
|
|
||||||
assertQuery("0000000000000000000000000000000000000000");
|
assertQuery("0000000000000000000000000000000000000000");
|
||||||
@@ -378,10 +348,10 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byOwner() throws Exception {
|
public void byOwner() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, userId.get(), null));
|
Change change1 = insert(repo, newChange(repo), userId);
|
||||||
int user2 = accountManager.authenticate(AuthRequest.forUser("anotheruser"))
|
Account.Id user2 = accountManager.authenticate(
|
||||||
.getAccountId().get();
|
AuthRequest.forUser("anotheruser")).getAccountId();
|
||||||
Change change2 = insert(newChange(repo, null, null, user2, null));
|
Change change2 = insert(repo, newChange(repo), user2);
|
||||||
|
|
||||||
assertQuery("owner:" + userId.get(), change1);
|
assertQuery("owner:" + userId.get(), change1);
|
||||||
assertQuery("owner:" + user2, change2);
|
assertQuery("owner:" + user2, change2);
|
||||||
@@ -390,7 +360,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byAuthor() throws Exception {
|
public void byAuthor() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, userId.get(), null));
|
Change change1 = insert(repo, newChange(repo), userId);
|
||||||
|
|
||||||
// By exact email address
|
// By exact email address
|
||||||
assertQuery("author:jauthor@example.com", change1);
|
assertQuery("author:jauthor@example.com", change1);
|
||||||
@@ -417,7 +387,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byCommitter() throws Exception {
|
public void byCommitter() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, userId.get(), null));
|
Change change1 = insert(repo, newChange(repo), userId);
|
||||||
|
|
||||||
// By exact email address
|
// By exact email address
|
||||||
assertQuery("committer:jcommitter@example.com", change1);
|
assertQuery("committer:jcommitter@example.com", change1);
|
||||||
@@ -444,10 +414,10 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byOwnerIn() throws Exception {
|
public void byOwnerIn() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, userId.get(), null));
|
Change change1 = insert(repo, newChange(repo), userId);
|
||||||
int user2 = accountManager.authenticate(AuthRequest.forUser("anotheruser"))
|
Account.Id user2 = accountManager.authenticate(
|
||||||
.getAccountId().get();
|
AuthRequest.forUser("anotheruser")).getAccountId();
|
||||||
Change change2 = insert(newChange(repo, null, null, user2, null));
|
Change change2 = insert(repo, newChange(repo), user2);
|
||||||
|
|
||||||
assertQuery("ownerin:Administrators", change1);
|
assertQuery("ownerin:Administrators", change1);
|
||||||
assertQuery("ownerin:\"Registered Users\"", change2, change1);
|
assertQuery("ownerin:\"Registered Users\"", change2, change1);
|
||||||
@@ -457,8 +427,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void byProject() throws Exception {
|
public void byProject() throws Exception {
|
||||||
TestRepository<Repo> repo1 = createProject("repo1");
|
TestRepository<Repo> repo1 = createProject("repo1");
|
||||||
TestRepository<Repo> repo2 = createProject("repo2");
|
TestRepository<Repo> repo2 = createProject("repo2");
|
||||||
Change change1 = insert(newChange(repo1, null, null, null, null));
|
Change change1 = insert(repo1, newChange(repo1));
|
||||||
Change change2 = insert(newChange(repo2, null, null, null, null));
|
Change change2 = insert(repo2, newChange(repo2));
|
||||||
|
|
||||||
assertQuery("project:foo");
|
assertQuery("project:foo");
|
||||||
assertQuery("project:repo");
|
assertQuery("project:repo");
|
||||||
@@ -470,8 +440,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void byProjectPrefix() throws Exception {
|
public void byProjectPrefix() throws Exception {
|
||||||
TestRepository<Repo> repo1 = createProject("repo1");
|
TestRepository<Repo> repo1 = createProject("repo1");
|
||||||
TestRepository<Repo> repo2 = createProject("repo2");
|
TestRepository<Repo> repo2 = createProject("repo2");
|
||||||
Change change1 = insert(newChange(repo1, null, null, null, null));
|
Change change1 = insert(repo1, newChange(repo1));
|
||||||
Change change2 = insert(newChange(repo2, null, null, null, null));
|
Change change2 = insert(repo2, newChange(repo2));
|
||||||
|
|
||||||
assertQuery("projects:foo");
|
assertQuery("projects:foo");
|
||||||
assertQuery("projects:repo1", change1);
|
assertQuery("projects:repo1", change1);
|
||||||
@@ -482,8 +452,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byBranchAndRef() throws Exception {
|
public void byBranchAndRef() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, "master"));
|
Change change1 = insert(repo, newChangeForBranch(repo, "master"));
|
||||||
Change change2 = insert(newChange(repo, null, null, null, "branch"));
|
Change change2 = insert(repo, newChangeForBranch(repo, "branch"));
|
||||||
|
|
||||||
assertQuery("branch:foo");
|
assertQuery("branch:foo");
|
||||||
assertQuery("branch:master", change1);
|
assertQuery("branch:master", change1);
|
||||||
@@ -500,27 +470,19 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byTopic() throws Exception {
|
public void byTopic() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins1 = newChange(repo, null, null, null, null);
|
ChangeInserter ins1 = newChangeWithTopic(repo, "feature1");
|
||||||
Change change1 = ins1.getChange();
|
Change change1 = insert(repo, ins1);
|
||||||
change1.setTopic("feature1");
|
|
||||||
insert(ins1);
|
|
||||||
|
|
||||||
ChangeInserter ins2 = newChange(repo, null, null, null, null);
|
ChangeInserter ins2 = newChangeWithTopic(repo, "feature2");
|
||||||
Change change2 = ins2.getChange();
|
Change change2 = insert(repo, ins2);
|
||||||
change2.setTopic("feature2");
|
|
||||||
insert(ins2);
|
|
||||||
|
|
||||||
ChangeInserter ins3 = newChange(repo, null, null, null, null);
|
ChangeInserter ins3 = newChangeWithTopic(repo, "Cherrypick-feature2");
|
||||||
Change change3 = ins3.getChange();
|
Change change3 = insert(repo, ins3);
|
||||||
change3.setTopic("Cherrypick-feature2");
|
|
||||||
insert(ins3);
|
|
||||||
|
|
||||||
ChangeInserter ins4 = newChange(repo, null, null, null, null);
|
ChangeInserter ins4 = newChangeWithTopic(repo, "feature2-fixup");
|
||||||
Change change4 = ins4.getChange();
|
Change change4 = insert(repo, ins4);
|
||||||
change4.setTopic("feature2-fixup");
|
|
||||||
insert(ins4);
|
|
||||||
|
|
||||||
Change change5 = insert(newChange(repo, null, null, null, null));
|
Change change5 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
assertQuery("intopic:foo");
|
assertQuery("intopic:foo");
|
||||||
assertQuery("intopic:feature1", change1);
|
assertQuery("intopic:feature1", change1);
|
||||||
@@ -536,9 +498,9 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void byMessageExact() throws Exception {
|
public void byMessageExact() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
RevCommit commit1 = repo.parseBody(repo.commit().message("one").create());
|
RevCommit commit1 = repo.parseBody(repo.commit().message("one").create());
|
||||||
Change change1 = insert(newChange(repo, commit1, null, null, null));
|
Change change1 = insert(repo, newChangeForCommit(repo, commit1));
|
||||||
RevCommit commit2 = repo.parseBody(repo.commit().message("two").create());
|
RevCommit commit2 = repo.parseBody(repo.commit().message("two").create());
|
||||||
Change change2 = insert(newChange(repo, commit2, null, null, null));
|
Change change2 = insert(repo, newChangeForCommit(repo, commit2));
|
||||||
|
|
||||||
assertQuery("message:foo");
|
assertQuery("message:foo");
|
||||||
assertQuery("message:one", change1);
|
assertQuery("message:one", change1);
|
||||||
@@ -550,10 +512,10 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
RevCommit commit1 =
|
RevCommit commit1 =
|
||||||
repo.parseBody(repo.commit().message("12345 67890").create());
|
repo.parseBody(repo.commit().message("12345 67890").create());
|
||||||
Change change1 = insert(newChange(repo, commit1, null, null, null));
|
Change change1 = insert(repo, newChangeForCommit(repo, commit1));
|
||||||
RevCommit commit2 =
|
RevCommit commit2 =
|
||||||
repo.parseBody(repo.commit().message("12346 67891").create());
|
repo.parseBody(repo.commit().message("12346 67891").create());
|
||||||
Change change2 = insert(newChange(repo, commit2, null, null, null));
|
Change change2 = insert(repo, newChangeForCommit(repo, commit2));
|
||||||
|
|
||||||
assertQuery("message:1234");
|
assertQuery("message:1234");
|
||||||
assertQuery("message:12345", change1);
|
assertQuery("message:12345", change1);
|
||||||
@@ -564,8 +526,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void byLabel() throws Exception {
|
public void byLabel() throws Exception {
|
||||||
accountManager.authenticate(AuthRequest.forUser("anotheruser"));
|
accountManager.authenticate(AuthRequest.forUser("anotheruser"));
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins = newChange(repo, null, null, null, null);
|
ChangeInserter ins = newChange(repo);
|
||||||
Change change = insert(ins);
|
Change change = insert(repo, ins);
|
||||||
|
|
||||||
gApi.changes().id(change.getId().get()).current()
|
gApi.changes().id(change.getId().get()).current()
|
||||||
.review(new ReviewInput().label("Code-Review", 1));
|
.review(new ReviewInput().label("Code-Review", 1));
|
||||||
@@ -627,8 +589,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
gApi.groups().id(g2).addMembers("user2");
|
gApi.groups().id(g2).addMembers("user2");
|
||||||
|
|
||||||
// create a change
|
// create a change
|
||||||
ChangeInserter ins = newChange(repo, null, null, user1.get(), null);
|
Change change1 = insert(repo, newChange(repo), user1);
|
||||||
Change change1 = insert(ins);
|
|
||||||
|
|
||||||
// post a review with user1
|
// post a review with user1
|
||||||
requestContext.setContext(newRequestContext(user1));
|
requestContext.setContext(newRequestContext(user1));
|
||||||
@@ -650,7 +611,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
Change last = null;
|
Change last = null;
|
||||||
int n = 5;
|
int n = 5;
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
last = insert(newChange(repo, null, null, null, null));
|
last = insert(repo, newChange(repo));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i <= n + 2; i++) {
|
for (int i = 1; i <= n + 2; i++) {
|
||||||
@@ -677,7 +638,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
List<Change> changes = Lists.newArrayList();
|
List<Change> changes = Lists.newArrayList();
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
changes.add(insert(newChange(repo, null, null, null, null)));
|
changes.add(insert(repo, newChange(repo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertQuery("status:new", changes.get(1), changes.get(0));
|
assertQuery("status:new", changes.get(1), changes.get(0));
|
||||||
@@ -691,7 +652,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
List<Change> changes = Lists.newArrayList();
|
List<Change> changes = Lists.newArrayList();
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
changes.add(insert(newChange(repo, null, null, null, null)));
|
changes.add(insert(repo, newChange(repo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertQuery("status:new limit:2", changes.get(2), changes.get(1));
|
assertQuery("status:new limit:2", changes.get(2), changes.get(1));
|
||||||
@@ -705,7 +666,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void maxPages() throws Exception {
|
public void maxPages() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change = insert(newChange(repo, null, null, null, null));
|
Change change = insert(repo, newChange(repo));
|
||||||
|
|
||||||
QueryRequest query = newQuery("status:new").withLimit(10);
|
QueryRequest query = newQuery("status:new").withLimit(10);
|
||||||
assertQuery(query, change);
|
assertQuery(query, change);
|
||||||
@@ -722,8 +683,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
List<ChangeInserter> inserters = Lists.newArrayList();
|
List<ChangeInserter> inserters = Lists.newArrayList();
|
||||||
List<Change> changes = Lists.newArrayList();
|
List<Change> changes = Lists.newArrayList();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
inserters.add(newChange(repo, null, null, null, null));
|
inserters.add(newChange(repo));
|
||||||
changes.add(insert(inserters.get(i)));
|
changes.add(insert(repo, inserters.get(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i : ImmutableList.of(2, 0, 1, 4, 3)) {
|
for (int i : ImmutableList.of(2, 0, 1, 4, 3)) {
|
||||||
@@ -744,9 +705,9 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void updatedOrderWithMinuteResolution() throws Exception {
|
public void updatedOrderWithMinuteResolution() throws Exception {
|
||||||
TestTimeUtil.resetWithClockStep(2, MINUTES);
|
TestTimeUtil.resetWithClockStep(2, MINUTES);
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins1 = newChange(repo, null, null, null, null);
|
ChangeInserter ins1 = newChange(repo);
|
||||||
Change change1 = insert(ins1);
|
Change change1 = insert(repo, ins1);
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
assertThat(lastUpdatedMs(change1)).isLessThan(lastUpdatedMs(change2));
|
assertThat(lastUpdatedMs(change1)).isLessThan(lastUpdatedMs(change2));
|
||||||
assertQuery("status:new", change2, change1);
|
assertQuery("status:new", change2, change1);
|
||||||
@@ -766,9 +727,9 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void updatedOrderWithSubMinuteResolution() throws Exception {
|
public void updatedOrderWithSubMinuteResolution() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins1 = newChange(repo, null, null, null, null);
|
ChangeInserter ins1 = newChange(repo);
|
||||||
Change change1 = insert(ins1);
|
Change change1 = insert(repo, ins1);
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
assertThat(lastUpdatedMs(change1)).isLessThan(lastUpdatedMs(change2));
|
assertThat(lastUpdatedMs(change1)).isLessThan(lastUpdatedMs(change2));
|
||||||
|
|
||||||
@@ -789,11 +750,11 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void filterOutMoreThanOnePageOfResults() throws Exception {
|
public void filterOutMoreThanOnePageOfResults() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change = insert(newChange(repo, null, null, userId.get(), null));
|
Change change = insert(repo, newChange(repo), userId);
|
||||||
int user2 = accountManager.authenticate(AuthRequest.forUser("anotheruser"))
|
Account.Id user2 = accountManager.authenticate(
|
||||||
.getAccountId().get();
|
AuthRequest.forUser("anotheruser")).getAccountId();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
insert(newChange(repo, null, null, user2, null));
|
insert(repo, newChange(repo), user2);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertQuery("status:new ownerin:Administrators", change);
|
assertQuery("status:new ownerin:Administrators", change);
|
||||||
@@ -803,10 +764,10 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void filterOutAllResults() throws Exception {
|
public void filterOutAllResults() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
int user2 = accountManager.authenticate(AuthRequest.forUser("anotheruser"))
|
Account.Id user2 = accountManager.authenticate(
|
||||||
.getAccountId().get();
|
AuthRequest.forUser("anotheruser")).getAccountId();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
insert(newChange(repo, null, null, user2, null));
|
insert(repo, newChange(repo), user2);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertQuery("status:new ownerin:Administrators");
|
assertQuery("status:new ownerin:Administrators");
|
||||||
@@ -820,7 +781,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
repo.commit().message("one")
|
repo.commit().message("one")
|
||||||
.add("dir/file1", "contents1").add("dir/file2", "contents2")
|
.add("dir/file1", "contents1").add("dir/file2", "contents2")
|
||||||
.create());
|
.create());
|
||||||
Change change = insert(newChange(repo, commit, null, null, null));
|
Change change = insert(repo, newChangeForCommit(repo, commit));
|
||||||
|
|
||||||
assertQuery("file:file");
|
assertQuery("file:file");
|
||||||
assertQuery("file:dir", change);
|
assertQuery("file:dir", change);
|
||||||
@@ -837,7 +798,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
repo.commit().message("one")
|
repo.commit().message("one")
|
||||||
.add("dir/file1", "contents1").add("dir/file2", "contents2")
|
.add("dir/file1", "contents1").add("dir/file2", "contents2")
|
||||||
.create());
|
.create());
|
||||||
Change change = insert(newChange(repo, commit, null, null, null));
|
Change change = insert(repo, newChangeForCommit(repo, commit));
|
||||||
|
|
||||||
assertQuery("file:.*file.*");
|
assertQuery("file:.*file.*");
|
||||||
assertQuery("file:^file.*"); // Whole path only.
|
assertQuery("file:^file.*"); // Whole path only.
|
||||||
@@ -851,7 +812,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
repo.commit().message("one")
|
repo.commit().message("one")
|
||||||
.add("dir/file1", "contents1").add("dir/file2", "contents2")
|
.add("dir/file1", "contents1").add("dir/file2", "contents2")
|
||||||
.create());
|
.create());
|
||||||
Change change = insert(newChange(repo, commit, null, null, null));
|
Change change = insert(repo, newChangeForCommit(repo, commit));
|
||||||
|
|
||||||
assertQuery("path:file");
|
assertQuery("path:file");
|
||||||
assertQuery("path:dir");
|
assertQuery("path:dir");
|
||||||
@@ -868,7 +829,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
repo.commit().message("one")
|
repo.commit().message("one")
|
||||||
.add("dir/file1", "contents1").add("dir/file2", "contents2")
|
.add("dir/file1", "contents1").add("dir/file2", "contents2")
|
||||||
.create());
|
.create());
|
||||||
Change change = insert(newChange(repo, commit, null, null, null));
|
Change change = insert(repo, newChangeForCommit(repo, commit));
|
||||||
|
|
||||||
assertQuery("path:.*file.*");
|
assertQuery("path:.*file.*");
|
||||||
assertQuery("path:^dir.file.*", change);
|
assertQuery("path:^dir.file.*", change);
|
||||||
@@ -877,8 +838,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byComment() throws Exception {
|
public void byComment() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
ChangeInserter ins = newChange(repo, null, null, null, null);
|
ChangeInserter ins = newChange(repo);
|
||||||
Change change = insert(ins);
|
Change change = insert(repo, ins);
|
||||||
|
|
||||||
ReviewInput input = new ReviewInput();
|
ReviewInput input = new ReviewInput();
|
||||||
input.message = "toplevel";
|
input.message = "toplevel";
|
||||||
@@ -899,8 +860,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
long thirtyHoursInMs = MILLISECONDS.convert(30, HOURS);
|
long thirtyHoursInMs = MILLISECONDS.convert(30, HOURS);
|
||||||
TestTimeUtil.resetWithClockStep(thirtyHoursInMs, MILLISECONDS);
|
TestTimeUtil.resetWithClockStep(thirtyHoursInMs, MILLISECONDS);
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
// Queried by AgePredicate constructor.
|
// Queried by AgePredicate constructor.
|
||||||
TestTimeUtil.setClockStep(0, MILLISECONDS);
|
TestTimeUtil.setClockStep(0, MILLISECONDS);
|
||||||
long now = TimeUtil.nowMs();
|
long now = TimeUtil.nowMs();
|
||||||
@@ -922,8 +883,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void byBefore() throws Exception {
|
public void byBefore() throws Exception {
|
||||||
TestTimeUtil.resetWithClockStep(30, HOURS);
|
TestTimeUtil.resetWithClockStep(30, HOURS);
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
TestTimeUtil.setClockStep(0, MILLISECONDS);
|
TestTimeUtil.setClockStep(0, MILLISECONDS);
|
||||||
|
|
||||||
assertQuery("before:2009-09-29");
|
assertQuery("before:2009-09-29");
|
||||||
@@ -942,8 +903,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void byAfter() throws Exception {
|
public void byAfter() throws Exception {
|
||||||
TestTimeUtil.resetWithClockStep(30, HOURS);
|
TestTimeUtil.resetWithClockStep(30, HOURS);
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
TestTimeUtil.setClockStep(0, MILLISECONDS);
|
TestTimeUtil.setClockStep(0, MILLISECONDS);
|
||||||
|
|
||||||
assertQuery("after:2009-10-03");
|
assertQuery("after:2009-10-03");
|
||||||
@@ -964,8 +925,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
RevCommit commit2 = repo.parseBody(
|
RevCommit commit2 = repo.parseBody(
|
||||||
repo.commit().parent(commit1).add("file1", "foo").create());
|
repo.commit().parent(commit1).add("file1", "foo").create());
|
||||||
|
|
||||||
Change change1 = insert(newChange(repo, commit1, null, null, null));
|
Change change1 = insert(repo, newChangeForCommit(repo, commit1));
|
||||||
Change change2 = insert(newChange(repo, commit2, null, null, null));
|
Change change2 = insert(repo, newChangeForCommit(repo, commit2));
|
||||||
|
|
||||||
assertQuery("added:>4");
|
assertQuery("added:>4");
|
||||||
assertQuery("-added:<=4");
|
assertQuery("-added:<=4");
|
||||||
@@ -1014,8 +975,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
|
|
||||||
private List<Change> setUpHashtagChanges() throws Exception {
|
private List<Change> setUpHashtagChanges() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
HashtagsInput in = new HashtagsInput();
|
HashtagsInput in = new HashtagsInput();
|
||||||
in.add = ImmutableSet.of("foo");
|
in.add = ImmutableSet.of("foo");
|
||||||
@@ -1057,31 +1018,29 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void byDefault() throws Exception {
|
public void byDefault() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
|
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
RevCommit commit2 = repo.parseBody(
|
RevCommit commit2 = repo.parseBody(
|
||||||
repo.commit().message("foosubject").create());
|
repo.commit().message("foosubject").create());
|
||||||
Change change2 = insert(newChange(repo, commit2, null, null, null));
|
Change change2 = insert(repo, newChangeForCommit(repo, commit2));
|
||||||
|
|
||||||
RevCommit commit3 = repo.parseBody(
|
RevCommit commit3 = repo.parseBody(
|
||||||
repo.commit()
|
repo.commit()
|
||||||
.add("Foo.java", "foo contents")
|
.add("Foo.java", "foo contents")
|
||||||
.create());
|
.create());
|
||||||
Change change3 = insert(newChange(repo, commit3, null, null, null));
|
Change change3 = insert(repo, newChangeForCommit(repo, commit3));
|
||||||
|
|
||||||
ChangeInserter ins4 = newChange(repo, null, null, null, null);
|
ChangeInserter ins4 = newChange(repo);
|
||||||
Change change4 = insert(ins4);
|
Change change4 = insert(repo, ins4);
|
||||||
ReviewInput ri4 = new ReviewInput();
|
ReviewInput ri4 = new ReviewInput();
|
||||||
ri4.message = "toplevel";
|
ri4.message = "toplevel";
|
||||||
ri4.labels = ImmutableMap.<String, Short> of("Code-Review", (short) 1);
|
ri4.labels = ImmutableMap.<String, Short> of("Code-Review", (short) 1);
|
||||||
gApi.changes().id(change4.getId().get()).current().review(ri4);
|
gApi.changes().id(change4.getId().get()).current().review(ri4);
|
||||||
|
|
||||||
ChangeInserter ins5 = newChange(repo, null, null, null, null);
|
ChangeInserter ins5 = newChangeWithTopic(repo, "feature5");
|
||||||
Change change5 = ins5.getChange();
|
Change change5 = insert(repo, ins5);
|
||||||
change5.setTopic("feature5");
|
|
||||||
insert(ins5);
|
|
||||||
|
|
||||||
Change change6 = insert(newChange(repo, null, null, null, "branch6"));
|
Change change6 = insert(repo, newChangeForBranch(repo, "branch6"));
|
||||||
|
|
||||||
assertQuery(change1.getId().get(), change1);
|
assertQuery(change1.getId().get(), change1);
|
||||||
assertQuery(ChangeTriplet.format(change1), change1);
|
assertQuery(ChangeTriplet.format(change1), change1);
|
||||||
@@ -1102,11 +1061,9 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void implicitVisibleTo() throws Exception {
|
public void implicitVisibleTo() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, userId.get(), null));
|
Change change1 = insert(repo, newChange(repo), userId);
|
||||||
ChangeInserter ins2 = newChange(repo, null, null, userId.get(), null);
|
Change change2 =
|
||||||
Change change2 = ins2.getChange();
|
insert(repo, newChangeWithStatus(repo, Change.Status.DRAFT), userId);
|
||||||
change2.setStatus(Change.Status.DRAFT);
|
|
||||||
insert(ins2);
|
|
||||||
|
|
||||||
String q = "project:repo";
|
String q = "project:repo";
|
||||||
assertQuery(q, change2, change1);
|
assertQuery(q, change2, change1);
|
||||||
@@ -1120,11 +1077,9 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void explicitVisibleTo() throws Exception {
|
public void explicitVisibleTo() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, userId.get(), null));
|
Change change1 = insert(repo, newChange(repo), userId);
|
||||||
ChangeInserter ins2 = newChange(repo, null, null, userId.get(), null);
|
Change change2 =
|
||||||
Change change2 = ins2.getChange();
|
insert(repo, newChangeWithStatus(repo, Change.Status.DRAFT), userId);
|
||||||
change2.setStatus(Change.Status.DRAFT);
|
|
||||||
insert(ins2);
|
|
||||||
|
|
||||||
String q = "project:repo";
|
String q = "project:repo";
|
||||||
assertQuery(q, change2, change1);
|
assertQuery(q, change2, change1);
|
||||||
@@ -1139,8 +1094,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byCommentBy() throws Exception {
|
public void byCommentBy() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
int user2 = accountManager.authenticate(AuthRequest.forUser("anotheruser"))
|
int user2 = accountManager.authenticate(AuthRequest.forUser("anotheruser"))
|
||||||
.getAccountId().get();
|
.getAccountId().get();
|
||||||
@@ -1165,8 +1120,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byDraftBy() throws Exception {
|
public void byDraftBy() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
DraftInput in = new DraftInput();
|
DraftInput in = new DraftInput();
|
||||||
in.line = 1;
|
in.line = 1;
|
||||||
@@ -1190,12 +1145,11 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byFrom() throws Exception {
|
public void byFrom() throws Exception {
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
int user2 = accountManager.authenticate(AuthRequest.forUser("anotheruser"))
|
Account.Id user2 = accountManager.authenticate(
|
||||||
.getAccountId().get();
|
AuthRequest.forUser("anotheruser")).getAccountId();
|
||||||
ChangeInserter ins2 = newChange(repo, null, null, user2, null);
|
Change change2 = insert(repo, newChange(repo), user2);
|
||||||
Change change2 = insert(ins2);
|
|
||||||
|
|
||||||
ReviewInput input = new ReviewInput();
|
ReviewInput input = new ReviewInput();
|
||||||
input.message = "toplevel";
|
input.message = "toplevel";
|
||||||
@@ -1231,10 +1185,10 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
repo.commit()
|
repo.commit()
|
||||||
.add("file4", "contents4")
|
.add("file4", "contents4")
|
||||||
.create());
|
.create());
|
||||||
Change change1 = insert(newChange(repo, commit1, null, null, null));
|
Change change1 = insert(repo, newChangeForCommit(repo, commit1));
|
||||||
Change change2 = insert(newChange(repo, commit2, null, null, null));
|
Change change2 = insert(repo, newChangeForCommit(repo, commit2));
|
||||||
Change change3 = insert(newChange(repo, commit3, null, null, null));
|
Change change3 = insert(repo, newChangeForCommit(repo, commit3));
|
||||||
Change change4 = insert(newChange(repo, commit4, null, null, null));
|
Change change4 = insert(repo, newChangeForCommit(repo, commit4));
|
||||||
|
|
||||||
assertQuery("conflicts:" + change1.getId().get(), change3);
|
assertQuery("conflicts:" + change1.getId().get(), change3);
|
||||||
assertQuery("conflicts:" + change2.getId().get());
|
assertQuery("conflicts:" + change2.getId().get());
|
||||||
@@ -1246,9 +1200,9 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void reviewedBy() throws Exception {
|
public void reviewedBy() throws Exception {
|
||||||
TestTimeUtil.resetWithClockStep(2, MINUTES);
|
TestTimeUtil.resetWithClockStep(2, MINUTES);
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change1 = insert(newChange(repo, null, null, null, null));
|
Change change1 = insert(repo, newChange(repo));
|
||||||
Change change2 = insert(newChange(repo, null, null, null, null));
|
Change change2 = insert(repo, newChange(repo));
|
||||||
Change change3 = insert(newChange(repo, null, null, null, null));
|
Change change3 = insert(repo, newChange(repo));
|
||||||
|
|
||||||
gApi.changes()
|
gApi.changes()
|
||||||
.id(change1.getId().get())
|
.id(change1.getId().get())
|
||||||
@@ -1303,8 +1257,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
List<Integer> expectedIds = new ArrayList<>(n);
|
List<Integer> expectedIds = new ArrayList<>(n);
|
||||||
Branch.NameKey dest = null;
|
Branch.NameKey dest = null;
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
ChangeInserter ins = newChange(repo, null, null, null, null);
|
ChangeInserter ins = newChange(repo);
|
||||||
insert(ins);
|
insert(repo, ins);
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
dest = ins.getChange().getDest();
|
dest = ins.getChange().getDest();
|
||||||
}
|
}
|
||||||
@@ -1333,7 +1287,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void prepopulatedFields() throws Exception {
|
public void prepopulatedFields() throws Exception {
|
||||||
assume().that(notesMigration.enabled()).isFalse();
|
assume().that(notesMigration.enabled()).isFalse();
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change = insert(newChange(repo, null, null, null, null));
|
Change change = insert(repo, newChange(repo));
|
||||||
|
|
||||||
db = new DisabledReviewDb();
|
db = new DisabledReviewDb();
|
||||||
requestContext.setContext(newRequestContext(userId));
|
requestContext.setContext(newRequestContext(userId));
|
||||||
@@ -1362,7 +1316,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
public void prepopulateOnlyRequestedFields() throws Exception {
|
public void prepopulateOnlyRequestedFields() throws Exception {
|
||||||
assume().that(notesMigration.enabled()).isFalse();
|
assume().that(notesMigration.enabled()).isFalse();
|
||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
Change change = insert(newChange(repo, null, null, null, null));
|
Change change = insert(repo, newChange(repo));
|
||||||
|
|
||||||
db = new DisabledReviewDb();
|
db = new DisabledReviewDb();
|
||||||
requestContext.setContext(newRequestContext(userId));
|
requestContext.setContext(newRequestContext(userId));
|
||||||
@@ -1383,46 +1337,64 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
cd.currentApprovals();
|
cd.currentApprovals();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ChangeInserter newChange(
|
protected ChangeInserter newChange(TestRepository<Repo> repo)
|
||||||
TestRepository<Repo> repo,
|
throws Exception {
|
||||||
@Nullable RevCommit commit, @Nullable String key, @Nullable Integer owner,
|
return newChange(repo, null, null, null, null);
|
||||||
@Nullable String branch) throws Exception {
|
}
|
||||||
|
|
||||||
|
protected ChangeInserter newChangeForCommit(TestRepository<Repo> repo,
|
||||||
|
RevCommit commit) throws Exception {
|
||||||
|
return newChange(repo, commit, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ChangeInserter newChangeForBranch(TestRepository<Repo> repo,
|
||||||
|
String branch) throws Exception {
|
||||||
|
return newChange(repo, null, branch, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ChangeInserter newChangeWithStatus(TestRepository<Repo> repo,
|
||||||
|
Change.Status status) throws Exception {
|
||||||
|
return newChange(repo, null, null, status, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ChangeInserter newChangeWithTopic(TestRepository<Repo> repo,
|
||||||
|
String topic) throws Exception {
|
||||||
|
return newChange(repo, null, null, null, topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ChangeInserter newChange(TestRepository<Repo> repo,
|
||||||
|
@Nullable RevCommit commit, @Nullable String branch,
|
||||||
|
@Nullable Change.Status status, @Nullable String topic) throws Exception {
|
||||||
if (commit == null) {
|
if (commit == null) {
|
||||||
commit = repo.parseBody(repo.commit().message("message").create());
|
commit = repo.parseBody(repo.commit().message("message").create());
|
||||||
}
|
}
|
||||||
Account.Id ownerId = owner != null ? new Account.Id(owner) : userId;
|
|
||||||
branch = MoreObjects.firstNonNull(branch, "refs/heads/master");
|
branch = MoreObjects.firstNonNull(branch, "refs/heads/master");
|
||||||
if (!branch.startsWith("refs/heads/")) {
|
if (!branch.startsWith("refs/heads/")) {
|
||||||
branch = "refs/heads/" + branch;
|
branch = "refs/heads/" + branch;
|
||||||
}
|
}
|
||||||
Project.NameKey project = new Project.NameKey(
|
|
||||||
repo.getRepository().getDescription().getRepositoryName());
|
|
||||||
|
|
||||||
Change.Id id = new Change.Id(seq.nextChangeId());
|
Change.Id id = new Change.Id(seq.nextChangeId());
|
||||||
if (key == null) {
|
ChangeInserter ins = changeFactory.create(
|
||||||
key = "I" + Hashing.sha1().newHasher()
|
id, commit, branch)
|
||||||
.putInt(id.get())
|
.setValidatePolicy(CommitValidators.Policy.NONE)
|
||||||
.putString(project.get(), UTF_8)
|
.setStatus(status)
|
||||||
.putString(commit.name(), UTF_8)
|
.setTopic(topic);
|
||||||
.putInt(ownerId.get())
|
return ins;
|
||||||
.putString(branch, UTF_8)
|
|
||||||
.hash()
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
Change change = new Change(new Change.Key(key), id, ownerId,
|
|
||||||
new Branch.NameKey(project, branch), TimeUtil.nowTs());
|
|
||||||
IdentifiedUser user = userFactory.create(Providers.of(db), ownerId);
|
|
||||||
RefControl refControl = projectControlFactory.controlFor(project, user)
|
|
||||||
.controlForRef(change.getDest());
|
|
||||||
return changeFactory.create(refControl, change, commit)
|
|
||||||
.setValidatePolicy(CommitValidators.Policy.NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Change insert(ChangeInserter ins) throws Exception {
|
protected Change insert(TestRepository<Repo> repo, ChangeInserter ins) throws Exception {
|
||||||
try (BatchUpdate bu = updateFactory.create(
|
return insert(repo, ins, null);
|
||||||
db, ins.getChange().getProject(), ins.getUser(),
|
}
|
||||||
ins.getChange().getCreatedOn())) {
|
|
||||||
|
protected Change insert(TestRepository<Repo> repo, ChangeInserter ins,
|
||||||
|
@Nullable Account.Id owner) throws Exception {
|
||||||
|
Project.NameKey project = new Project.NameKey(
|
||||||
|
repo.getRepository().getDescription().getRepositoryName());
|
||||||
|
Account.Id ownerId = owner != null ? owner : userId;
|
||||||
|
IdentifiedUser user = userFactory.create(Providers.of(db), ownerId);
|
||||||
|
try (BatchUpdate bu =
|
||||||
|
updateFactory.create(db, project, user, TimeUtil.nowTs())) {
|
||||||
bu.insertChange(ins);
|
bu.insertChange(ins);
|
||||||
bu.execute();
|
bu.execute();
|
||||||
return ins.getChange();
|
return ins.getChange();
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ public class LuceneQueryChangesTest extends AbstractQueryChangesTest {
|
|||||||
TestRepository<Repo> repo = createProject("repo");
|
TestRepository<Repo> repo = createProject("repo");
|
||||||
RevCommit commit1 =
|
RevCommit commit1 =
|
||||||
repo.parseBody(repo.commit().message("foo_bar_foo").create());
|
repo.parseBody(repo.commit().message("foo_bar_foo").create());
|
||||||
Change change1 = insert(newChange(repo, commit1, null, null, null));
|
Change change1 = insert(repo, newChangeForCommit(repo, commit1));
|
||||||
RevCommit commit2 =
|
RevCommit commit2 =
|
||||||
repo.parseBody(repo.commit().message("one.two.three").create());
|
repo.parseBody(repo.commit().message("one.two.three").create());
|
||||||
Change change2 = insert(newChange(repo, commit2, null, null, null));
|
Change change2 = insert(repo, newChangeForCommit(repo, commit2));
|
||||||
|
|
||||||
assertQuery("message:foo_ba");
|
assertQuery("message:foo_ba");
|
||||||
assertQuery("message:bar", change1);
|
assertQuery("message:bar", change1);
|
||||||
|
|||||||
Reference in New Issue
Block a user