Search in sources :

Example 36 with BatchRefUpdate

use of org.eclipse.jgit.lib.BatchRefUpdate in project gerrit by GerritCodeReview.

the class CommitRewriterTest method cleanUp.

@After
public void cleanUp() throws Exception {
    BatchRefUpdate bru = repo.getRefDatabase().newBatchUpdate();
    bru.setAllowNonFastForwards(true);
    for (Ref ref : repo.getRefDatabase().getRefsByPrefix(RefNames.REFS_CHANGES)) {
        Change.Id changeId = Change.Id.fromRef(ref.getName());
        if (changeId == null || !ref.getName().equals(RefNames.changeMetaRef(changeId))) {
            continue;
        }
        bru.addCommand(new ReceiveCommand(ref.getObjectId(), ObjectId.zeroId(), ref.getName()));
    }
    RefUpdateUtil.executeChecked(bru, repo);
}
Also used : ReceiveCommand(org.eclipse.jgit.transport.ReceiveCommand) Ref(org.eclipse.jgit.lib.Ref) Change(com.google.gerrit.entities.Change) BatchRefUpdate(org.eclipse.jgit.lib.BatchRefUpdate) After(org.junit.After)

Aggregations

BatchRefUpdate (org.eclipse.jgit.lib.BatchRefUpdate)36 ReceiveCommand (org.eclipse.jgit.transport.ReceiveCommand)20 IOException (java.io.IOException)16 Repository (org.eclipse.jgit.lib.Repository)16 RevWalk (org.eclipse.jgit.revwalk.RevWalk)15 OrmException (com.google.gwtorm.server.OrmException)8 Map (java.util.Map)7 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)7 Ref (org.eclipse.jgit.lib.Ref)7 Account (com.google.gerrit.reviewdb.client.Account)6 MetaDataUpdate (com.google.gerrit.server.git.MetaDataUpdate)6 ObjectId (org.eclipse.jgit.lib.ObjectId)5 ObjectInserter (org.eclipse.jgit.lib.ObjectInserter)5 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)4 ResultSet (java.sql.ResultSet)4 Statement (java.sql.Statement)4 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)3 AnyObjectId (org.eclipse.jgit.lib.AnyObjectId)3 NullProgressMonitor (org.eclipse.jgit.lib.NullProgressMonitor)3 RefUpdate (org.eclipse.jgit.lib.RefUpdate)3