Search in sources :

Example 1 with GerritPersonIdentProvider

use of com.google.gerrit.server.GerritPersonIdentProvider in project gerrit by GerritCodeReview.

the class ExternalIdsOnInit method insert.

public synchronized void insert(String commitMessage, Collection<ExternalId> extIds) throws OrmException, IOException, ConfigInvalidException {
    File path = getPath();
    if (path != null) {
        try (Repository repo = new FileRepository(path);
            RevWalk rw = new RevWalk(repo);
            ObjectInserter ins = repo.newObjectInserter()) {
            ObjectId rev = ExternalIdReader.readRevision(repo);
            NoteMap noteMap = ExternalIdReader.readNoteMap(rw, rev);
            for (ExternalId extId : extIds) {
                ExternalIdsUpdate.insert(rw, ins, noteMap, extId);
            }
            PersonIdent serverIdent = new GerritPersonIdentProvider(flags.cfg).get();
            ExternalIdsUpdate.commit(repo, rw, ins, rev, noteMap, commitMessage, serverIdent, serverIdent);
        }
    }
}
Also used : FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) Repository(org.eclipse.jgit.lib.Repository) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) ObjectId(org.eclipse.jgit.lib.ObjectId) PersonIdent(org.eclipse.jgit.lib.PersonIdent) ExternalId(com.google.gerrit.server.account.externalids.ExternalId) GerritPersonIdentProvider(com.google.gerrit.server.GerritPersonIdentProvider) NoteMap(org.eclipse.jgit.notes.NoteMap) RevWalk(org.eclipse.jgit.revwalk.RevWalk) File(java.io.File)

Example 2 with GerritPersonIdentProvider

use of com.google.gerrit.server.GerritPersonIdentProvider in project gerrit by GerritCodeReview.

the class AccountsOnInit method insert.

public void insert(ReviewDb db, Account account) throws OrmException, IOException {
    db.accounts().insert(ImmutableSet.of(account));
    File path = getPath();
    if (path != null) {
        try (Repository repo = new FileRepository(path);
            ObjectInserter oi = repo.newObjectInserter()) {
            PersonIdent serverIdent = new GerritPersonIdentProvider(flags.cfg).get();
            AccountsUpdate.createUserBranch(repo, oi, serverIdent, serverIdent, account);
        }
    }
}
Also used : FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) Repository(org.eclipse.jgit.lib.Repository) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GerritPersonIdentProvider(com.google.gerrit.server.GerritPersonIdentProvider) File(java.io.File)

Aggregations

GerritPersonIdentProvider (com.google.gerrit.server.GerritPersonIdentProvider)2 File (java.io.File)2 FileRepository (org.eclipse.jgit.internal.storage.file.FileRepository)2 ObjectInserter (org.eclipse.jgit.lib.ObjectInserter)2 PersonIdent (org.eclipse.jgit.lib.PersonIdent)2 Repository (org.eclipse.jgit.lib.Repository)2 ExternalId (com.google.gerrit.server.account.externalids.ExternalId)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 NoteMap (org.eclipse.jgit.notes.NoteMap)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1