use of com.google.gerrit.extensions.common.GitPerson in project gerrit by GerritCodeReview.
the class CreateChangeIT method createDefaultAuthor.
@Test
public void createDefaultAuthor() throws Exception {
ChangeInput input = newChangeInput(ChangeStatus.NEW);
ChangeInfo info = assertCreateSucceeds(input);
GitPerson person = gApi.changes().id(info.id).current().commit(false).author;
assertThat(person).email().isEqualTo(admin.email());
}
use of com.google.gerrit.extensions.common.GitPerson in project gerrit by GerritCodeReview.
the class ChangeIT method testRebase.
private void testRebase(Rebase rebase) throws Exception {
// Create two changes both with the same parent
PushOneCommit.Result r = createChange();
testRepo.reset("HEAD~1");
PushOneCommit.Result r2 = createChange();
// Approve and submit the first change
RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
revision.review(ReviewInput.approve());
revision.submit();
// Add an approval whose score should be copied on trivial rebase
gApi.changes().id(r2.getChangeId()).current().review(ReviewInput.recommend());
String changeId = r2.getChangeId();
// Rebase the second change
rebase.call(changeId);
// Second change should have 2 patch sets and an approval
ChangeInfo c2 = gApi.changes().id(changeId).get(CURRENT_REVISION, DETAILED_LABELS);
assertThat(c2.revisions.get(c2.currentRevision)._number).isEqualTo(2);
// ...and the committer and description should be correct
ChangeInfo info = gApi.changes().id(changeId).get(CURRENT_REVISION, CURRENT_COMMIT);
GitPerson committer = info.revisions.get(info.currentRevision).commit.committer;
assertThat(committer.name).isEqualTo(admin.fullName());
assertThat(committer.email).isEqualTo(admin.email());
String description = info.revisions.get(info.currentRevision).description;
assertThat(description).isEqualTo("Rebase");
// ...and the approval was copied
LabelInfo cr = c2.labels.get(LabelId.CODE_REVIEW);
assertThat(cr).isNotNull();
assertThat(cr.all).hasSize(1);
assertThat(cr.all.get(0).value).isEqualTo(1);
// Rebasing the second change again should fail
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.changes().id(changeId).current().rebase());
assertThat(thrown).hasMessageThat().contains("Change is already up to date");
}
use of com.google.gerrit.extensions.common.GitPerson in project gerrit by GerritCodeReview.
the class CommonConverters method toGitPerson.
// TODO(issue-15517): Fix the JdkObsolete issue with Date once JGit's PersonIdent class supports
// Instants
@SuppressWarnings("JdkObsolete")
public static GitPerson toGitPerson(PersonIdent ident) {
GitPerson result = new GitPerson();
result.name = ident.getName();
result.email = ident.getEmailAddress();
result.setDate(ident.getWhen().toInstant());
result.tz = ident.getTimeZoneOffset();
return result;
}
use of com.google.gerrit.extensions.common.GitPerson in project gerrit by GerritCodeReview.
the class CreateChangeIT method createMergeChangeAuthor.
@Test
public void createMergeChangeAuthor() throws Exception {
changeInTwoBranches("branchA", "a.txt", "branchB", "b.txt");
ChangeInput in = newMergeChangeInput("branchA", "branchB", "");
in.author = new AccountInput();
in.author.name = "Gerritless Jane";
in.author.email = "gerritlessjane@invalid";
ChangeInfo change = assertCreateSucceeds(in);
RevisionApi rApi = gApi.changes().id(change.id).current();
GitPerson author = rApi.commit(false).author;
assertThat(author).email().isEqualTo(in.author.email);
GitPerson committer = rApi.commit(false).committer;
assertThat(committer).email().isEqualTo(admin.getNameEmail().email());
}
use of com.google.gerrit.extensions.common.GitPerson in project gerrit by GerritCodeReview.
the class CreateChangeIT method createAuthorOverride.
@Test
public void createAuthorOverride() throws Exception {
ChangeInput input = newChangeInput(ChangeStatus.NEW);
input.author = new AccountInput();
input.author.email = "gerritlessjane@invalid";
// This is an email address that doesn't exist as account on the Gerrit server.
input.author.name = "Gerritless Jane";
ChangeInfo info = assertCreateSucceeds(input);
RevisionApi rApi = gApi.changes().id(info.id).current();
GitPerson author = rApi.commit(false).author;
assertThat(author).email().isEqualTo(input.author.email);
assertThat(author).name().isEqualTo(input.author.name);
GitPerson committer = rApi.commit(false).committer;
assertThat(committer).email().isEqualTo(admin.getNameEmail().email());
}
Aggregations