Search in sources :

Example 21 with BranchNameKey

use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.

the class CreateBranchIT method conflictingBranchAlreadyExists_Conflict.

@Test
public void conflictingBranchAlreadyExists_Conflict() throws Exception {
    assertCreateSucceeds(testBranch);
    BranchNameKey testBranch2 = BranchNameKey.create(project, testBranch.branch() + "/foo/bar");
    assertCreateFails(testBranch2, ResourceConflictException.class, "Cannot create branch \"" + testBranch2.branch() + "\" since it conflicts with branch \"" + testBranch.branch() + "\"");
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 22 with BranchNameKey

use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.

the class DeleteBranchIT method deleteRefsForBranch.

@Test
public void deleteRefsForBranch() throws Exception {
    BranchNameKey refsForBranch = BranchNameKey.create(project, "refs/for/master");
    // the remote repo.
    try (TestRepository<Repository> repo = new TestRepository<>(repoManager.openRepository(project))) {
        repo.branch(refsForBranch.branch()).commit().message("Initial empty commit").create();
    }
    assertThat(branch(refsForBranch).get().canDelete).isTrue();
    String branchRev = branch(refsForBranch).get().revision;
    branch(refsForBranch).delete();
    eventRecorder.assertRefUpdatedEvents(project.get(), refsForBranch.branch(), branchRev, null);
    assertThrows(ResourceNotFoundException.class, () -> branch(refsForBranch).get());
}
Also used : TestRepository(org.eclipse.jgit.junit.TestRepository) Repository(org.eclipse.jgit.lib.Repository) TestRepository(org.eclipse.jgit.junit.TestRepository) BranchNameKey(com.google.gerrit.entities.BranchNameKey) IdString(com.google.gerrit.extensions.restapi.IdString) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 23 with BranchNameKey

use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.

the class BranchNameKeyProtoConverterTest method allValuesConvertedToProto.

@Test
public void allValuesConvertedToProto() {
    BranchNameKey nameKey = BranchNameKey.create(Project.nameKey("project-13"), "branch-72");
    Entities.Branch_NameKey proto = branchNameKeyProtoConverter.toProto(nameKey);
    Entities.Branch_NameKey expectedProto = Entities.Branch_NameKey.newBuilder().setProject(Entities.Project_NameKey.newBuilder().setName("project-13")).setBranch("refs/heads/branch-72").build();
    assertThat(proto).isEqualTo(expectedProto);
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) Entities(com.google.gerrit.proto.Entities) Test(org.junit.Test)

Example 24 with BranchNameKey

use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.

the class PermissionBackendConditionIT method refPermissions_sameResourceAndUserEquals.

@Test
public void refPermissions_sameResourceAndUserEquals() throws Exception {
    BranchNameKey branch = BranchNameKey.create(project, "branch");
    BooleanCondition cond1 = pb.user(user()).ref(branch).testCond(RefPermission.READ);
    BooleanCondition cond2 = pb.user(user()).ref(branch).testCond(RefPermission.READ);
    assertEquals(cond1, cond2);
    assertEquals(cond1.hashCode(), cond2.hashCode());
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) BooleanCondition(com.google.gerrit.extensions.conditions.BooleanCondition) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 25 with BranchNameKey

use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.

the class StreamEventsApiListener method onGitReferenceUpdated.

@Override
public void onGitReferenceUpdated(GitReferenceUpdatedListener.Event ev) {
    RefUpdatedEvent event = new RefUpdatedEvent();
    if (ev.getUpdater() != null) {
        event.submitter = accountAttributeSupplier(ev.getUpdater());
    }
    final BranchNameKey refName = BranchNameKey.create(ev.getProjectName(), ev.getRefName());
    event.refUpdate = Suppliers.memoize(() -> eventFactory.asRefUpdateAttribute(ObjectId.fromString(ev.getOldObjectId()), ObjectId.fromString(ev.getNewObjectId()), refName));
    dispatcher.run(d -> d.postEvent(refName, event));
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey)

Aggregations

BranchNameKey (com.google.gerrit.entities.BranchNameKey)75 Test (org.junit.Test)48 Project (com.google.gerrit.entities.Project)26 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)25 Config (org.eclipse.jgit.lib.Config)19 SubmoduleSubscription (com.google.gerrit.entities.SubmoduleSubscription)18 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)16 RevCommit (org.eclipse.jgit.revwalk.RevCommit)16 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)15 AuthException (com.google.gerrit.extensions.restapi.AuthException)13 Change (com.google.gerrit.entities.Change)12 IOException (java.io.IOException)11 ObjectId (org.eclipse.jgit.lib.ObjectId)11 StorageException (com.google.gerrit.exceptions.StorageException)10 ChangeData (com.google.gerrit.server.query.change.ChangeData)9 Repository (org.eclipse.jgit.lib.Repository)9 PatchSet (com.google.gerrit.entities.PatchSet)8 CodeReviewCommit (com.google.gerrit.server.git.CodeReviewCommit)8 HashMap (java.util.HashMap)7 Ref (org.eclipse.jgit.lib.Ref)7