Merge branch 'stable-2.15' into stable-2.16
* stable-2.15: ListChangesOption: Add missing word in Javadoc Update git submodules AccountIT#updateDisplayName: Rewrite to work with updated account manager AccountApiImpl: Fix message in exception RelatedChangeAndCommitInfo: Use default CommitInfo#toString Support Get Related in extension API CommitInfo: Use ToStringHelper CommitInfo: Handle root commits in toString() Implement equals/hashCode/toString in CommitInfo and friends Set version to 2.15.9-SNAPSHOT AccountIT: Disable failing updateDisplayName test Change-Id: Id2c1ad86a3f5ebb62a932b02d315330ae7a11102
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2018 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.extensions.api.changes;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
|
import com.google.gerrit.extensions.common.CommitInfo;
|
||||||
|
|
||||||
|
public class RelatedChangeAndCommitInfo {
|
||||||
|
public String project;
|
||||||
|
public String changeId;
|
||||||
|
public CommitInfo commit;
|
||||||
|
public Integer _changeNumber;
|
||||||
|
public Integer _revisionNumber;
|
||||||
|
public Integer _currentRevisionNumber;
|
||||||
|
public String status;
|
||||||
|
|
||||||
|
public RelatedChangeAndCommitInfo() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return MoreObjects.toStringHelper(this)
|
||||||
|
.add("project", project)
|
||||||
|
.add("changeId", changeId)
|
||||||
|
.add("commit", commit)
|
||||||
|
.add("_changeNumber", _changeNumber)
|
||||||
|
.add("_revisionNumber", _revisionNumber)
|
||||||
|
.add("_currentRevisionNumber", _currentRevisionNumber)
|
||||||
|
.add("status", status)
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (C) 2018 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.extensions.api.changes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RelatedChangesInfo {
|
||||||
|
public List<RelatedChangeAndCommitInfo> changes;
|
||||||
|
}
|
@@ -133,6 +133,8 @@ public interface RevisionApi {
|
|||||||
|
|
||||||
MergeListRequest getMergeList() throws RestApiException;
|
MergeListRequest getMergeList() throws RestApiException;
|
||||||
|
|
||||||
|
RelatedChangesInfo related() throws RestApiException;
|
||||||
|
|
||||||
abstract class MergeListRequest {
|
abstract class MergeListRequest {
|
||||||
private boolean addLinks;
|
private boolean addLinks;
|
||||||
private int uninterestingParent = 1;
|
private int uninterestingParent = 1;
|
||||||
@@ -370,6 +372,11 @@ public interface RevisionApi {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelatedChangesInfo related() throws RestApiException {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void description(String description) throws RestApiException {
|
public void description(String description) throws RestApiException {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
@@ -17,7 +17,7 @@ package com.google.gerrit.extensions.client;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/** Output options available for retrieval change details. */
|
/** Output options available for retrieval of change details. */
|
||||||
public enum ListChangesOption {
|
public enum ListChangesOption {
|
||||||
LABELS(0),
|
LABELS(0),
|
||||||
DETAILED_LABELS(8),
|
DETAILED_LABELS(8),
|
||||||
|
@@ -16,6 +16,8 @@ package com.google.gerrit.extensions.common;
|
|||||||
|
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
|
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -50,17 +52,18 @@ public class CommitInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// Using something like the raw commit format might be nice, but we can't depend on JGit here.
|
ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(commit);
|
||||||
StringBuilder sb = new StringBuilder().append(getClass().getSimpleName()).append('{');
|
if (parents != null) {
|
||||||
sb.append(commit);
|
helper.add("parents", parents.stream().map(p -> p.commit).collect(joining(", ")));
|
||||||
sb.append(", parents=").append(parents.stream().map(p -> p.commit).collect(joining(", ")));
|
|
||||||
sb.append(", author=").append(author);
|
|
||||||
sb.append(", committer=").append(committer);
|
|
||||||
sb.append(", subject=").append(subject);
|
|
||||||
sb.append(", message=").append(message);
|
|
||||||
if (webLinks != null) {
|
|
||||||
sb.append(", webLinks=").append(webLinks);
|
|
||||||
}
|
}
|
||||||
return sb.append('}').toString();
|
helper
|
||||||
|
.add("author", author)
|
||||||
|
.add("committer", committer)
|
||||||
|
.add("subject", subject)
|
||||||
|
.add("message", message);
|
||||||
|
if (webLinks != null) {
|
||||||
|
helper.add("webLinks", webLinks);
|
||||||
|
}
|
||||||
|
return helper.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -228,7 +228,7 @@ public class AccountApiImpl implements AccountApi {
|
|||||||
accountLoader.fill();
|
accountLoader.fill();
|
||||||
return ai;
|
return ai;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw asRestApiException("Cannot parse change", e);
|
throw asRestApiException("Cannot parse account", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@ import com.google.gerrit.extensions.api.changes.DraftApi;
|
|||||||
import com.google.gerrit.extensions.api.changes.DraftInput;
|
import com.google.gerrit.extensions.api.changes.DraftInput;
|
||||||
import com.google.gerrit.extensions.api.changes.FileApi;
|
import com.google.gerrit.extensions.api.changes.FileApi;
|
||||||
import com.google.gerrit.extensions.api.changes.RebaseInput;
|
import com.google.gerrit.extensions.api.changes.RebaseInput;
|
||||||
|
import com.google.gerrit.extensions.api.changes.RelatedChangesInfo;
|
||||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||||
import com.google.gerrit.extensions.api.changes.ReviewResult;
|
import com.google.gerrit.extensions.api.changes.ReviewResult;
|
||||||
import com.google.gerrit.extensions.api.changes.RevisionApi;
|
import com.google.gerrit.extensions.api.changes.RevisionApi;
|
||||||
@@ -64,6 +65,7 @@ import com.google.gerrit.server.restapi.change.GetCommit;
|
|||||||
import com.google.gerrit.server.restapi.change.GetDescription;
|
import com.google.gerrit.server.restapi.change.GetDescription;
|
||||||
import com.google.gerrit.server.restapi.change.GetMergeList;
|
import com.google.gerrit.server.restapi.change.GetMergeList;
|
||||||
import com.google.gerrit.server.restapi.change.GetPatch;
|
import com.google.gerrit.server.restapi.change.GetPatch;
|
||||||
|
import com.google.gerrit.server.restapi.change.GetRelated;
|
||||||
import com.google.gerrit.server.restapi.change.GetRevisionActions;
|
import com.google.gerrit.server.restapi.change.GetRevisionActions;
|
||||||
import com.google.gerrit.server.restapi.change.ListRevisionComments;
|
import com.google.gerrit.server.restapi.change.ListRevisionComments;
|
||||||
import com.google.gerrit.server.restapi.change.ListRevisionDrafts;
|
import com.google.gerrit.server.restapi.change.ListRevisionDrafts;
|
||||||
@@ -129,6 +131,7 @@ class RevisionApiImpl implements RevisionApi {
|
|||||||
private final TestSubmitType.Get getSubmitType;
|
private final TestSubmitType.Get getSubmitType;
|
||||||
private final Provider<TestSubmitRule> testSubmitRule;
|
private final Provider<TestSubmitRule> testSubmitRule;
|
||||||
private final Provider<GetMergeList> getMergeList;
|
private final Provider<GetMergeList> getMergeList;
|
||||||
|
private final GetRelated getRelated;
|
||||||
private final PutDescription putDescription;
|
private final PutDescription putDescription;
|
||||||
private final GetDescription getDescription;
|
private final GetDescription getDescription;
|
||||||
|
|
||||||
@@ -169,6 +172,7 @@ class RevisionApiImpl implements RevisionApi {
|
|||||||
TestSubmitType.Get getSubmitType,
|
TestSubmitType.Get getSubmitType,
|
||||||
Provider<TestSubmitRule> testSubmitRule,
|
Provider<TestSubmitRule> testSubmitRule,
|
||||||
Provider<GetMergeList> getMergeList,
|
Provider<GetMergeList> getMergeList,
|
||||||
|
GetRelated getRelated,
|
||||||
PutDescription putDescription,
|
PutDescription putDescription,
|
||||||
GetDescription getDescription,
|
GetDescription getDescription,
|
||||||
@Assisted RevisionResource r) {
|
@Assisted RevisionResource r) {
|
||||||
@@ -207,6 +211,7 @@ class RevisionApiImpl implements RevisionApi {
|
|||||||
this.getSubmitType = getSubmitType;
|
this.getSubmitType = getSubmitType;
|
||||||
this.testSubmitRule = testSubmitRule;
|
this.testSubmitRule = testSubmitRule;
|
||||||
this.getMergeList = getMergeList;
|
this.getMergeList = getMergeList;
|
||||||
|
this.getRelated = getRelated;
|
||||||
this.putDescription = putDescription;
|
this.putDescription = putDescription;
|
||||||
this.getDescription = getDescription;
|
this.getDescription = getDescription;
|
||||||
this.revision = r;
|
this.revision = r;
|
||||||
@@ -589,6 +594,15 @@ class RevisionApiImpl implements RevisionApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelatedChangesInfo related() throws RestApiException {
|
||||||
|
try {
|
||||||
|
return getRelated.apply(revision);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw asRestApiException("Cannot get related changes", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void description(String description) throws RestApiException {
|
public void description(String description) throws RestApiException {
|
||||||
DescriptionInput in = new DescriptionInput();
|
DescriptionInput in = new DescriptionInput();
|
||||||
|
@@ -17,9 +17,10 @@ package com.google.gerrit.server.restapi.change;
|
|||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.MoreObjects;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
|
import com.google.gerrit.extensions.api.changes.RelatedChangeAndCommitInfo;
|
||||||
|
import com.google.gerrit.extensions.api.changes.RelatedChangesInfo;
|
||||||
import com.google.gerrit.extensions.common.CommitInfo;
|
import com.google.gerrit.extensions.common.CommitInfo;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.index.IndexConfig;
|
import com.google.gerrit.index.IndexConfig;
|
||||||
@@ -70,15 +71,15 @@ public class GetRelated implements RestReadView<RevisionResource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelatedInfo apply(RevisionResource rsrc)
|
public RelatedChangesInfo apply(RevisionResource rsrc)
|
||||||
throws RepositoryNotFoundException, IOException, OrmException, NoSuchProjectException,
|
throws RepositoryNotFoundException, IOException, OrmException, NoSuchProjectException,
|
||||||
PermissionBackendException {
|
PermissionBackendException {
|
||||||
RelatedInfo relatedInfo = new RelatedInfo();
|
RelatedChangesInfo relatedChangesInfo = new RelatedChangesInfo();
|
||||||
relatedInfo.changes = getRelated(rsrc);
|
relatedChangesInfo.changes = getRelated(rsrc);
|
||||||
return relatedInfo;
|
return relatedChangesInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ChangeAndCommit> getRelated(RevisionResource rsrc)
|
private List<RelatedChangeAndCommitInfo> getRelated(RevisionResource rsrc)
|
||||||
throws OrmException, IOException, PermissionBackendException {
|
throws OrmException, IOException, PermissionBackendException {
|
||||||
Set<String> groups = getAllGroups(rsrc.getNotes(), db.get(), psUtil);
|
Set<String> groups = getAllGroups(rsrc.getNotes(), db.get(), psUtil);
|
||||||
if (groups.isEmpty()) {
|
if (groups.isEmpty()) {
|
||||||
@@ -94,7 +95,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
|
|||||||
if (cds.size() == 1 && cds.get(0).getId().equals(rsrc.getChange().getId())) {
|
if (cds.size() == 1 && cds.get(0).getId().equals(rsrc.getChange().getId())) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
List<ChangeAndCommit> result = new ArrayList<>(cds.size());
|
List<RelatedChangeAndCommitInfo> result = new ArrayList<>(cds.size());
|
||||||
|
|
||||||
boolean isEdit = rsrc.getEdit().isPresent();
|
boolean isEdit = rsrc.getEdit().isPresent();
|
||||||
PatchSet basePs = isEdit ? rsrc.getEdit().get().getBasePatchSet() : rsrc.getPatchSet();
|
PatchSet basePs = isEdit ? rsrc.getEdit().get().getBasePatchSet() : rsrc.getPatchSet();
|
||||||
@@ -111,11 +112,11 @@ public class GetRelated implements RestReadView<RevisionResource> {
|
|||||||
} else {
|
} else {
|
||||||
commit = d.commit();
|
commit = d.commit();
|
||||||
}
|
}
|
||||||
result.add(new ChangeAndCommit(rsrc.getProject(), d.data().change(), ps, commit));
|
result.add(newChangeAndCommit(rsrc.getProject(), d.data().change(), ps, commit));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.size() == 1) {
|
if (result.size() == 1) {
|
||||||
ChangeAndCommit r = result.get(0);
|
RelatedChangeAndCommitInfo r = result.get(0);
|
||||||
if (r.commit != null && r.commit.commit.equals(rsrc.getPatchSet().getRevision().get())) {
|
if (r.commit != null && r.commit.commit.equals(rsrc.getPatchSet().getRevision().get())) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@@ -143,69 +144,30 @@ public class GetRelated implements RestReadView<RevisionResource> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RelatedInfo {
|
static RelatedChangeAndCommitInfo newChangeAndCommit(
|
||||||
public List<ChangeAndCommit> changes;
|
Project.NameKey project, @Nullable Change change, @Nullable PatchSet ps, RevCommit c) {
|
||||||
}
|
RelatedChangeAndCommitInfo info = new RelatedChangeAndCommitInfo();
|
||||||
|
info.project = project.get();
|
||||||
|
|
||||||
public static class ChangeAndCommit {
|
if (change != null) {
|
||||||
public String project;
|
info.changeId = change.getKey().get();
|
||||||
public String changeId;
|
info._changeNumber = change.getChangeId();
|
||||||
public CommitInfo commit;
|
info._revisionNumber = ps != null ? ps.getPatchSetId() : null;
|
||||||
public Integer _changeNumber;
|
PatchSet.Id curr = change.currentPatchSetId();
|
||||||
public Integer _revisionNumber;
|
info._currentRevisionNumber = curr != null ? curr.get() : null;
|
||||||
public Integer _currentRevisionNumber;
|
info.status = change.getStatus().asChangeStatus().toString();
|
||||||
public String status;
|
|
||||||
|
|
||||||
public ChangeAndCommit() {}
|
|
||||||
|
|
||||||
ChangeAndCommit(
|
|
||||||
Project.NameKey project, @Nullable Change change, @Nullable PatchSet ps, RevCommit c) {
|
|
||||||
this.project = project.get();
|
|
||||||
|
|
||||||
if (change != null) {
|
|
||||||
changeId = change.getKey().get();
|
|
||||||
_changeNumber = change.getChangeId();
|
|
||||||
_revisionNumber = ps != null ? ps.getPatchSetId() : null;
|
|
||||||
PatchSet.Id curr = change.currentPatchSetId();
|
|
||||||
_currentRevisionNumber = curr != null ? curr.get() : null;
|
|
||||||
status = change.getStatus().asChangeStatus().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
commit = new CommitInfo();
|
|
||||||
commit.commit = c.name();
|
|
||||||
commit.parents = Lists.newArrayListWithCapacity(c.getParentCount());
|
|
||||||
for (int i = 0; i < c.getParentCount(); i++) {
|
|
||||||
CommitInfo p = new CommitInfo();
|
|
||||||
p.commit = c.getParent(i).name();
|
|
||||||
commit.parents.add(p);
|
|
||||||
}
|
|
||||||
commit.author = CommonConverters.toGitPerson(c.getAuthorIdent());
|
|
||||||
commit.subject = c.getShortMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
info.commit = new CommitInfo();
|
||||||
public String toString() {
|
info.commit.commit = c.name();
|
||||||
return MoreObjects.toStringHelper(this)
|
info.commit.parents = Lists.newArrayListWithCapacity(c.getParentCount());
|
||||||
.add("project", project)
|
for (int i = 0; i < c.getParentCount(); i++) {
|
||||||
.add("changeId", changeId)
|
CommitInfo p = new CommitInfo();
|
||||||
.add("commit", toString(commit))
|
p.commit = c.getParent(i).name();
|
||||||
.add("_changeNumber", _changeNumber)
|
info.commit.parents.add(p);
|
||||||
.add("_revisionNumber", _revisionNumber)
|
|
||||||
.add("_currentRevisionNumber", _currentRevisionNumber)
|
|
||||||
.add("status", status)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String toString(CommitInfo commit) {
|
|
||||||
return MoreObjects.toStringHelper(commit)
|
|
||||||
.add("commit", commit.commit)
|
|
||||||
.add("parent", commit.parents)
|
|
||||||
.add("author", commit.author)
|
|
||||||
.add("committer", commit.committer)
|
|
||||||
.add("subject", commit.subject)
|
|
||||||
.add("message", commit.message)
|
|
||||||
.add("webLinks", commit.webLinks)
|
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
info.commit.author = CommonConverters.toGitPerson(c.getAuthorIdent());
|
||||||
|
info.commit.subject = c.getShortMessage();
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,9 +24,10 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
import com.google.gerrit.acceptance.GerritConfig;
|
import com.google.gerrit.acceptance.GerritConfig;
|
||||||
|
import com.google.gerrit.acceptance.NoHttpd;
|
||||||
import com.google.gerrit.acceptance.PushOneCommit;
|
import com.google.gerrit.acceptance.PushOneCommit;
|
||||||
import com.google.gerrit.acceptance.RestResponse;
|
|
||||||
import com.google.gerrit.common.RawInputUtil;
|
import com.google.gerrit.common.RawInputUtil;
|
||||||
|
import com.google.gerrit.extensions.api.changes.RelatedChangeAndCommitInfo;
|
||||||
import com.google.gerrit.extensions.common.CommitInfo;
|
import com.google.gerrit.extensions.common.CommitInfo;
|
||||||
import com.google.gerrit.extensions.common.EditInfo;
|
import com.google.gerrit.extensions.common.EditInfo;
|
||||||
import com.google.gerrit.index.IndexConfig;
|
import com.google.gerrit.index.IndexConfig;
|
||||||
@@ -35,8 +36,6 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
|||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.restapi.change.ChangesCollection;
|
import com.google.gerrit.server.restapi.change.ChangesCollection;
|
||||||
import com.google.gerrit.server.restapi.change.GetRelated;
|
import com.google.gerrit.server.restapi.change.GetRelated;
|
||||||
import com.google.gerrit.server.restapi.change.GetRelated.ChangeAndCommit;
|
|
||||||
import com.google.gerrit.server.restapi.change.GetRelated.RelatedInfo;
|
|
||||||
import com.google.gerrit.server.update.BatchUpdate;
|
import com.google.gerrit.server.update.BatchUpdate;
|
||||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||||
import com.google.gerrit.server.update.ChangeContext;
|
import com.google.gerrit.server.update.ChangeContext;
|
||||||
@@ -56,6 +55,7 @@ import org.junit.After;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@NoHttpd
|
||||||
public class GetRelatedIT extends AbstractDaemonTest {
|
public class GetRelatedIT extends AbstractDaemonTest {
|
||||||
private static final int MAX_TERMS = 10;
|
private static final int MAX_TERMS = 10;
|
||||||
|
|
||||||
@@ -577,15 +577,12 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
|||||||
assertRelated(cd.change().currentPatchSetId());
|
assertRelated(cd.change().currentPatchSetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ChangeAndCommit> getRelated(PatchSet.Id ps) throws Exception {
|
private List<RelatedChangeAndCommitInfo> getRelated(PatchSet.Id ps) throws Exception {
|
||||||
return getRelated(ps.getParentKey(), ps.get());
|
return getRelated(ps.getParentKey(), ps.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ChangeAndCommit> getRelated(Change.Id changeId, int ps) throws Exception {
|
private List<RelatedChangeAndCommitInfo> getRelated(Change.Id changeId, int ps) throws Exception {
|
||||||
String url = String.format("/changes/%d/revisions/%d/related", changeId.get(), ps);
|
return gApi.changes().id(changeId.get()).revision(ps).related().changes;
|
||||||
RestResponse r = adminRestSession.get(url);
|
|
||||||
r.assertOK();
|
|
||||||
return newGson().fromJson(r.getReader(), RelatedInfo.class).changes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RevCommit parseBody(RevCommit c) throws Exception {
|
private RevCommit parseBody(RevCommit c) throws Exception {
|
||||||
@@ -601,9 +598,9 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
|||||||
return Iterables.getOnlyElement(queryProvider.get().byCommit(c));
|
return Iterables.getOnlyElement(queryProvider.get().byCommit(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChangeAndCommit changeAndCommit(
|
private RelatedChangeAndCommitInfo changeAndCommit(
|
||||||
PatchSet.Id psId, ObjectId commitId, int currentRevisionNum) {
|
PatchSet.Id psId, ObjectId commitId, int currentRevisionNum) {
|
||||||
ChangeAndCommit result = new ChangeAndCommit();
|
RelatedChangeAndCommitInfo result = new RelatedChangeAndCommitInfo();
|
||||||
result.project = project.get();
|
result.project = project.get();
|
||||||
result._changeNumber = psId.getParentKey().get();
|
result._changeNumber = psId.getParentKey().get();
|
||||||
result.commit = new CommitInfo();
|
result.commit = new CommitInfo();
|
||||||
@@ -631,13 +628,14 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertRelated(PatchSet.Id psId, ChangeAndCommit... expected) throws Exception {
|
private void assertRelated(PatchSet.Id psId, RelatedChangeAndCommitInfo... expected)
|
||||||
List<ChangeAndCommit> actual = getRelated(psId);
|
throws Exception {
|
||||||
|
List<RelatedChangeAndCommitInfo> actual = getRelated(psId);
|
||||||
assertThat(actual).named("related to " + psId).hasSize(expected.length);
|
assertThat(actual).named("related to " + psId).hasSize(expected.length);
|
||||||
for (int i = 0; i < actual.size(); i++) {
|
for (int i = 0; i < actual.size(); i++) {
|
||||||
String name = "index " + i + " related to " + psId;
|
String name = "index " + i + " related to " + psId;
|
||||||
ChangeAndCommit a = actual.get(i);
|
RelatedChangeAndCommitInfo a = actual.get(i);
|
||||||
ChangeAndCommit e = expected[i];
|
RelatedChangeAndCommitInfo e = expected[i];
|
||||||
assertThat(a.project).named("project of " + name).isEqualTo(e.project);
|
assertThat(a.project).named("project of " + name).isEqualTo(e.project);
|
||||||
assertThat(a._changeNumber).named("change ID of " + name).isEqualTo(e._changeNumber);
|
assertThat(a._changeNumber).named("change ID of " + name).isEqualTo(e._changeNumber);
|
||||||
// Don't bother checking changeId; assume _changeNumber is sufficient.
|
// Don't bother checking changeId; assume _changeNumber is sufficient.
|
||||||
|
Submodule plugins/download-commands updated: edd7156184...ce8f07234c
Reference in New Issue
Block a user