Search in sources :

Example 81 with ReceiveCommand

use of org.eclipse.jgit.transport.ReceiveCommand in project gerrit by GerritCodeReview.

the class RepoViewTest method getRefsOverwritesCachedValueWithCommand.

@Test
public void getRefsOverwritesCachedValueWithCommand() throws Exception {
    ObjectId master1 = repo.exactRef(MASTER).getObjectId();
    assertThat(view.getRef(MASTER)).hasValue(master1);
    ObjectId master2 = tr.commit().create();
    view.getCommands().add(new ReceiveCommand(master1, master2, MASTER));
    assertThat(repo.exactRef(MASTER).getObjectId()).isEqualTo(master1);
    assertThat(view.getRef(MASTER)).hasValue(master2);
    assertThat(view.getRefs(R_HEADS)).containsExactly("master", master2);
    view.getCommands().add(new ReceiveCommand(master2, ObjectId.zeroId(), MASTER));
    assertThat(repo.exactRef(MASTER).getObjectId()).isEqualTo(master1);
    assertThat(view.getRef(MASTER)).isEmpty();
    assertThat(view.getRefs(R_HEADS)).isEmpty();
}
Also used : ReceiveCommand(org.eclipse.jgit.transport.ReceiveCommand) ObjectId(org.eclipse.jgit.lib.ObjectId) Test(org.junit.Test)

Example 82 with ReceiveCommand

use of org.eclipse.jgit.transport.ReceiveCommand in project gerrit by GerritCodeReview.

the class RepoViewTest method getRefsReflectsCommands.

@Test
public void getRefsReflectsCommands() throws Exception {
    ObjectId master1 = repo.exactRef(MASTER).getObjectId();
    assertThat(view.getRefs(R_HEADS)).containsExactly("master", master1);
    ObjectId master2 = tr.commit().create();
    view.getCommands().add(new ReceiveCommand(master1, master2, MASTER));
    assertThat(repo.exactRef(MASTER).getObjectId()).isEqualTo(master1);
    assertThat(view.getRef(MASTER)).hasValue(master2);
    assertThat(view.getRefs(R_HEADS)).containsExactly("master", master2);
    view.getCommands().add(new ReceiveCommand(master2, ObjectId.zeroId(), MASTER));
    assertThat(repo.exactRef(MASTER).getObjectId()).isEqualTo(master1);
    assertThat(view.getRef(MASTER)).isEmpty();
    assertThat(view.getRefs(R_HEADS)).isEmpty();
}
Also used : ReceiveCommand(org.eclipse.jgit.transport.ReceiveCommand) ObjectId(org.eclipse.jgit.lib.ObjectId) Test(org.junit.Test)

Aggregations

ReceiveCommand (org.eclipse.jgit.transport.ReceiveCommand)82 IOException (java.io.IOException)29 ArrayList (java.util.ArrayList)23 ObjectId (org.eclipse.jgit.lib.ObjectId)23 BatchRefUpdate (org.eclipse.jgit.lib.BatchRefUpdate)22 RevWalk (org.eclipse.jgit.revwalk.RevWalk)21 Repository (org.eclipse.jgit.lib.Repository)19 Ref (org.eclipse.jgit.lib.Ref)18 Test (org.junit.Test)16 RepositoryModel (com.gitblit.models.RepositoryModel)13 Map (java.util.Map)13 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)11 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)10 StorageException (com.google.gerrit.exceptions.StorageException)9 ObjectInserter (org.eclipse.jgit.lib.ObjectInserter)9 PersonIdent (org.eclipse.jgit.lib.PersonIdent)9 RevCommit (org.eclipse.jgit.revwalk.RevCommit)9 AuthException (com.google.gerrit.extensions.restapi.AuthException)8 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)8 Collection (java.util.Collection)8