use of org.eclipse.jgit.lib.PersonIdent in project gitiles by GerritCodeReview.
the class IdentRevFilterTest method caseSensitiveEmailLocalPart.
@Test
public void caseSensitiveEmailLocalPart() throws Exception {
IdentRevFilter filter = IdentRevFilter.author("eSt");
assertThat(filter.matchesPerson(new PersonIdent("null", "est@google.com"))).isFalse();
assertThat(filter.matchesPerson(new PersonIdent("null", "Establish@google.com"))).isFalse();
assertThat(filter.matchesPerson(new PersonIdent("null", "tESt@google.com"))).isFalse();
assertThat(filter.matchesPerson(new PersonIdent("null", "tesTing@google.com"))).isFalse();
}
use of org.eclipse.jgit.lib.PersonIdent in project gitiles by GerritCodeReview.
the class IdentRevFilterTest method matchesEmailDomain.
@Test
public void matchesEmailDomain() throws Exception {
// git log --author matches the email domain as well as the enail name.
IdentRevFilter filter = IdentRevFilter.author("eSt");
assertThat(filter.matchesPerson(new PersonIdent("null", "null@eSt.com"))).isTrue();
assertThat(filter.matchesPerson(new PersonIdent("null", "null@eStablish.com"))).isTrue();
assertThat(filter.matchesPerson(new PersonIdent("null", "null@teSt.com"))).isTrue();
assertThat(filter.matchesPerson(new PersonIdent("null", "null@teSting.com"))).isTrue();
}
use of org.eclipse.jgit.lib.PersonIdent in project gitiles by GerritCodeReview.
the class IdentRevFilterTest method caseSensitiveEmailDomain.
@Test
public void caseSensitiveEmailDomain() throws Exception {
IdentRevFilter filter = IdentRevFilter.author("eSt");
assertThat(filter.matchesPerson(new PersonIdent("null", "null@est.com"))).isFalse();
assertThat(filter.matchesPerson(new PersonIdent("null", "null@Establish.com"))).isFalse();
assertThat(filter.matchesPerson(new PersonIdent("null", "null@tESt.com"))).isFalse();
assertThat(filter.matchesPerson(new PersonIdent("null", "null@tesTing.com"))).isFalse();
}
use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class CreateMergePatchSet method applyImpl.
@Override
protected Response<ChangeInfo> applyImpl(BatchUpdate.Factory updateFactory, ChangeResource rsrc, MergePatchSetInput in) throws OrmException, IOException, InvalidChangeOperationException, RestApiException, UpdateException, PermissionBackendException {
rsrc.permissions().database(db).check(ChangePermission.ADD_PATCH_SET);
MergeInput merge = in.merge;
if (merge == null || Strings.isNullOrEmpty(merge.source)) {
throw new BadRequestException("merge.source must be non-empty");
}
ChangeControl ctl = rsrc.getControl();
PatchSet ps = psUtil.current(db.get(), ctl.getNotes());
ProjectControl projectControl = ctl.getProjectControl();
Change change = ctl.getChange();
Project.NameKey project = change.getProject();
Branch.NameKey dest = change.getDest();
try (Repository git = gitManager.openRepository(project);
ObjectInserter oi = git.newObjectInserter();
ObjectReader reader = oi.newReader();
RevWalk rw = new RevWalk(reader)) {
RevCommit sourceCommit = MergeUtil.resolveCommit(git, rw, merge.source);
if (!projectControl.canReadCommit(db.get(), git, sourceCommit)) {
throw new ResourceNotFoundException("cannot find source commit: " + merge.source + " to merge.");
}
RevCommit currentPsCommit = rw.parseCommit(ObjectId.fromString(ps.getRevision().get()));
Timestamp now = TimeUtil.nowTs();
IdentifiedUser me = user.get().asIdentifiedUser();
PersonIdent author = me.newCommitterIdent(now, serverTimeZone);
RevCommit newCommit = createMergeCommit(in, projectControl, dest, git, oi, rw, currentPsCommit, sourceCommit, author, ObjectId.fromString(change.getKey().get().substring(1)));
PatchSet.Id nextPsId = ChangeUtil.nextPatchSetId(ps.getId());
PatchSetInserter psInserter = patchSetInserterFactory.create(ctl, nextPsId, newCommit);
try (BatchUpdate bu = updateFactory.create(db.get(), project, me, now)) {
bu.setRepository(git, rw, oi);
bu.addOp(ctl.getId(), psInserter.setMessage("Uploaded patch set " + nextPsId.get() + ".").setDraft(ps.isDraft()).setNotify(NotifyHandling.NONE).setCheckAddPatchSetPermission(false));
bu.execute();
}
ChangeJson json = jsonFactory.create(ListChangesOption.CURRENT_REVISION);
return Response.ok(json.format(psInserter.getChange()));
}
}
use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class GetPatch method formatEmailHeader.
private static String formatEmailHeader(RevCommit commit) {
StringBuilder b = new StringBuilder();
PersonIdent author = commit.getAuthorIdent();
String subject = commit.getShortMessage();
String msg = commit.getFullMessage().substring(subject.length());
if (msg.startsWith("\n\n")) {
msg = msg.substring(2);
}
b.append("From ").append(commit.getName()).append(' ').append(// Fixed timestamp to match output of C Git's format-patch
"Mon Sep 17 00:00:00 2001\n").append("From: ").append(author.getName()).append(" <").append(author.getEmailAddress()).append(">\n").append("Date: ").append(formatDate(author)).append('\n').append("Subject: [PATCH] ").append(subject).append('\n').append('\n').append(msg);
if (!msg.endsWith("\n")) {
b.append('\n');
}
return b.append("---\n\n").toString();
}
Aggregations