use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class GerritPublicKeyCheckerTest method add.
private void add(PGPPublicKeyRing kr, IdentifiedUser user) throws Exception {
Account.Id id = user.getAccountId();
List<ExternalId> newExtIds = new ArrayList<>(2);
newExtIds.add(ExternalId.create(toExtIdKey(kr.getPublicKey()), id));
@SuppressWarnings("unchecked") String userId = (String) Iterators.getOnlyElement(kr.getPublicKey().getUserIDs(), null);
if (userId != null) {
String email = PushCertificateIdent.parse(userId).getEmailAddress();
assertThat(email).contains("@");
newExtIds.add(ExternalId.createEmail(id, email));
}
store.add(kr);
PersonIdent ident = new PersonIdent("A U Thor", "author@example.com");
CommitBuilder cb = new CommitBuilder();
cb.setAuthor(ident);
cb.setCommitter(ident);
assertThat(store.save(cb)).isAnyOf(NEW, FAST_FORWARD, FORCED);
externalIdsUpdateFactory.create().insert(newExtIds);
accountCache.evict(user.getAccountId());
}
use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class PushCertificateCheckerTest method setUp.
@Before
public void setUp() throws Exception {
TestKey key1 = validKeyWithoutExpiration();
TestKey key3 = expiredKey();
repo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
store = new PublicKeyStore(repo);
store.add(key1.getPublicKeyRing());
store.add(key3.getPublicKeyRing());
PersonIdent ident = new PersonIdent("A U Thor", "author@example.com");
CommitBuilder cb = new CommitBuilder();
cb.setAuthor(ident);
cb.setCommitter(ident);
assertEquals(RefUpdate.Result.NEW, store.save(cb));
signedPushConfig = new SignedPushConfig();
signedPushConfig.setCertNonceSeed("sekret");
signedPushConfig.setCertNonceSlopLimit(60 * 24);
checker = newChecker(true);
}
use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class PublicKeyCheckerTest method save.
private void save() throws Exception {
PersonIdent ident = new PersonIdent("A U Thor", "author@example.com");
CommitBuilder cb = new CommitBuilder();
cb.setAuthor(ident);
cb.setCommitter(ident);
RefUpdate.Result result = store.save(cb);
switch(result) {
case NEW:
case FAST_FORWARD:
case FORCED:
break;
case IO_FAILURE:
case LOCK_FAILURE:
case NOT_ATTEMPTED:
case NO_CHANGE:
case REJECTED:
case REJECTED_CURRENT_BRANCH:
case RENAMED:
default:
throw new AssertionError(result);
}
}
use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.
the class MergeOneOp method updateRepoImpl.
@Override
public void updateRepoImpl(RepoContext ctx) throws IntegrationException, IOException {
PersonIdent caller = ctx.getIdentifiedUser().newCommitterIdent(ctx.getWhen(), ctx.getTimeZone());
if (args.mergeTip.getCurrentTip() == null) {
throw new IllegalStateException("cannot merge commit " + toMerge.name() + " onto a null tip; expected at least one fast-forward prior to" + " this operation");
}
CodeReviewCommit merged = args.mergeUtil.mergeOneCommit(caller, args.serverIdent, args.rw, ctx.getInserter(), ctx.getRepoView().getConfig(), args.destBranch, args.mergeTip.getCurrentTip(), toMerge);
args.mergeTip.moveTipTo(amendGitlink(merged), toMerge);
}
use of org.eclipse.jgit.lib.PersonIdent in project gitiles by GerritCodeReview.
the class BlameCacheImpl method loadRegions.
private static List<Region> loadRegions(BlameGenerator gen) throws IOException {
Map<ObjectId, PooledCommit> commits = Maps.newHashMap();
Interner<String> strings = Interners.newStrongInterner();
int lineCount = gen.getResultContents().size();
List<Region> regions = Lists.newArrayList();
while (gen.next()) {
String path = gen.getSourcePath();
PersonIdent author = gen.getSourceAuthor();
ObjectId commit = gen.getSourceCommit();
checkState(path != null && author != null && commit != null);
PooledCommit pc = commits.get(commit);
if (pc == null) {
pc = new PooledCommit(commit.copy(), new PersonIdent(strings.intern(author.getName()), strings.intern(author.getEmailAddress()), author.getWhen(), author.getTimeZone()));
commits.put(pc.commit, pc);
}
path = strings.intern(path);
commit = pc.commit;
author = pc.author;
regions.add(new Region(path, commit, author, gen.getResultStart(), gen.getResultEnd()));
}
Collections.sort(regions);
// Fill in any gaps left by bugs in JGit, since rendering code assumes the
// full set of contiguous regions.
List<Region> result = Lists.newArrayListWithExpectedSize(regions.size());
Region last = null;
for (Region r : regions) {
if (last != null) {
checkState(last.getEnd() <= r.getStart());
if (last.getEnd() < r.getStart()) {
result.add(new Region(null, null, null, last.getEnd(), r.getStart()));
}
}
result.add(r);
last = r;
}
if (last != null && last.getEnd() != lineCount) {
result.add(new Region(null, null, null, last.getEnd(), lineCount));
}
return ImmutableList.copyOf(result);
}
Aggregations