Search in sources :

Example 26 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class ActionJson method format.

public Map<String, ActionInfo> format(RevisionResource rsrc) {
    ChangeInfo changeInfo = null;
    RevisionInfo revisionInfo = null;
    List<ActionVisitor> visitors = visitors();
    if (!visitors.isEmpty()) {
        changeInfo = changeJson().format(rsrc);
        revisionInfo = requireNonNull(Iterables.getOnlyElement(changeInfo.revisions.values()));
        changeInfo.revisions = null;
    }
    return toActionMap(rsrc, visitors, changeInfo, revisionInfo);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) ActionVisitor(com.google.gerrit.extensions.api.changes.ActionVisitor)

Example 27 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class ActionJson method copy.

private ChangeInfo copy(List<ActionVisitor> visitors, ChangeInfo changeInfo) {
    if (visitors.isEmpty()) {
        return null;
    }
    // Include all fields from ChangeJson#toChangeInfoImpl that are not protected by any
    // ListChangesOptions.
    ChangeInfo copy = new ChangeInfo();
    copy.project = changeInfo.project;
    copy.branch = changeInfo.branch;
    copy.topic = changeInfo.topic;
    copy.attentionSet = changeInfo.attentionSet == null ? null : ImmutableMap.copyOf(changeInfo.attentionSet);
    copy.removedFromAttentionSet = changeInfo.removedFromAttentionSet == null ? null : ImmutableMap.copyOf(changeInfo.removedFromAttentionSet);
    copy.assignee = changeInfo.assignee;
    copy.hashtags = changeInfo.hashtags;
    copy.changeId = changeInfo.changeId;
    copy.submitType = changeInfo.submitType;
    copy.mergeable = changeInfo.mergeable;
    copy.insertions = changeInfo.insertions;
    copy.deletions = changeInfo.deletions;
    copy.hasReviewStarted = changeInfo.hasReviewStarted;
    copy.isPrivate = changeInfo.isPrivate;
    copy.subject = changeInfo.subject;
    copy.status = changeInfo.status;
    copy.owner = changeInfo.owner;
    copy.created = changeInfo.created;
    copy.updated = changeInfo.updated;
    copy._number = changeInfo._number;
    copy.requirements = changeInfo.requirements;
    copy.revertOf = changeInfo.revertOf;
    copy.submissionId = changeInfo.submissionId;
    copy.starred = changeInfo.starred;
    copy.stars = changeInfo.stars;
    copy.submitted = changeInfo.submitted;
    copy.submitter = changeInfo.submitter;
    copy.unresolvedCommentCount = changeInfo.unresolvedCommentCount;
    copy.workInProgress = changeInfo.workInProgress;
    copy.id = changeInfo.id;
    copy.cherryPickOfChange = changeInfo.cherryPickOfChange;
    copy.cherryPickOfPatchSet = changeInfo.cherryPickOfPatchSet;
    return copy;
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo)

Example 28 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class CheckProjectIT method detectAutoCloseableChangeByChangeId.

@Test
public void detectAutoCloseableChangeByChangeId() throws Exception {
    PushOneCommit.Result r = createChange("refs/for/master");
    String branch = r.getChange().change().getDest().branch();
    RevCommit amendedCommit = serverSideTestRepo.amend(r.getCommit()).create();
    serverSideTestRepo.branch(branch).update(amendedCommit);
    ChangeInfo info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
    CheckProjectResultInfo checkResult = gApi.projects().name(project.get()).check(checkProjectInputForAutoCloseableCheck(branch));
    assertThat(checkResult.autoCloseableChangesCheckResult.autoCloseableChanges.stream().map(i -> i._number).collect(toSet())).containsExactly(r.getChange().getId().get());
    info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
}
Also used : GitUtil.pushHead(com.google.gerrit.acceptance.GitUtil.pushHead) Iterables(com.google.common.collect.Iterables) TestRepository(org.eclipse.jgit.junit.TestRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) Test(org.junit.Test) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) Truth.assertThat(com.google.common.truth.Truth.assertThat) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) PersonIdent(org.eclipse.jgit.lib.PersonIdent) InheritableBoolean(com.google.gerrit.extensions.client.InheritableBoolean) ProjectsConsistencyChecker(com.google.gerrit.server.project.ProjectsConsistencyChecker) Collectors.toList(java.util.stream.Collectors.toList) CheckProjectResultInfo(com.google.gerrit.extensions.api.projects.CheckProjectResultInfo) CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GerritJUnit.assertThrows(com.google.gerrit.testing.GerritJUnit.assertThrows) AutoCloseableChangesCheckInput(com.google.gerrit.extensions.api.projects.CheckProjectInput.AutoCloseableChangesCheckInput) Collectors.toSet(java.util.stream.Collectors.toSet) ChangeStatus(com.google.gerrit.extensions.client.ChangeStatus) Before(org.junit.Before) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) CheckProjectResultInfo(com.google.gerrit.extensions.api.projects.CheckProjectResultInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 29 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class CheckProjectIT method maxCommits.

@Test
public void maxCommits() throws Exception {
    PushOneCommit.Result r = createChange("refs/for/master");
    String branch = r.getChange().change().getDest().branch();
    RevCommit amendedCommit = serverSideTestRepo.amend(r.getCommit()).create();
    serverSideTestRepo.branch(branch).update(amendedCommit);
    serverSideTestRepo.commit(amendedCommit);
    ChangeInfo info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
    CheckProjectInput input = checkProjectInputForAutoCloseableCheck(branch);
    input.autoCloseableChangesCheck.fix = true;
    input.autoCloseableChangesCheck.maxCommits = 1;
    CheckProjectResultInfo checkResult = gApi.projects().name(project.get()).check(input);
    assertThat(checkResult.autoCloseableChangesCheckResult.autoCloseableChanges).isEmpty();
    info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
    input.autoCloseableChangesCheck.maxCommits = 2;
    checkResult = gApi.projects().name(project.get()).check(input);
    assertThat(checkResult.autoCloseableChangesCheckResult.autoCloseableChanges.stream().map(i -> i._number).collect(toSet())).containsExactly(r.getChange().getId().get());
    info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.MERGED);
}
Also used : GitUtil.pushHead(com.google.gerrit.acceptance.GitUtil.pushHead) Iterables(com.google.common.collect.Iterables) TestRepository(org.eclipse.jgit.junit.TestRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) Test(org.junit.Test) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) Truth.assertThat(com.google.common.truth.Truth.assertThat) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) PersonIdent(org.eclipse.jgit.lib.PersonIdent) InheritableBoolean(com.google.gerrit.extensions.client.InheritableBoolean) ProjectsConsistencyChecker(com.google.gerrit.server.project.ProjectsConsistencyChecker) Collectors.toList(java.util.stream.Collectors.toList) CheckProjectResultInfo(com.google.gerrit.extensions.api.projects.CheckProjectResultInfo) CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GerritJUnit.assertThrows(com.google.gerrit.testing.GerritJUnit.assertThrows) AutoCloseableChangesCheckInput(com.google.gerrit.extensions.api.projects.CheckProjectInput.AutoCloseableChangesCheckInput) Collectors.toSet(java.util.stream.Collectors.toSet) ChangeStatus(com.google.gerrit.extensions.client.ChangeStatus) Before(org.junit.Before) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) CheckProjectResultInfo(com.google.gerrit.extensions.api.projects.CheckProjectResultInfo) CheckProjectInput(com.google.gerrit.extensions.api.projects.CheckProjectInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 30 with ChangeInfo

use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.

the class CheckProjectIT method noProblem.

@Test
public void noProblem() throws Exception {
    PushOneCommit.Result r = createChange("refs/for/master");
    String branch = r.getChange().change().getDest().branch();
    ChangeInfo info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
    CheckProjectResultInfo checkResult = gApi.projects().name(project.get()).check(checkProjectInputForAutoCloseableCheck(branch));
    assertThat(checkResult.autoCloseableChangesCheckResult.autoCloseableChanges).isEmpty();
    info = change(r).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) CheckProjectResultInfo(com.google.gerrit.extensions.api.projects.CheckProjectResultInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)504 Test (org.junit.Test)434 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)393 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)276 Change (com.google.gerrit.entities.Change)73 RevCommit (org.eclipse.jgit.revwalk.RevCommit)67 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)52 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)50 Project (com.google.gerrit.entities.Project)45 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)45 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)36 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)36 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)35 Repository (org.eclipse.jgit.lib.Repository)35 CommitInfo (com.google.gerrit.extensions.common.CommitInfo)32 LabelInfo (com.google.gerrit.extensions.common.LabelInfo)32 TestRepository (org.eclipse.jgit.junit.TestRepository)32 ObjectId (org.eclipse.jgit.lib.ObjectId)30 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)29 List (java.util.List)29