Search in sources :

Example 16 with TagInfo

use of com.google.gerrit.extensions.api.projects.TagInfo in project gerrit by GerritCodeReview.

the class TagsIT method listTagsOfNonVisibleBranch.

@Test
public void listTagsOfNonVisibleBranch() throws Exception {
    grantTagPermissions();
    // Allow creating a new hidden branch
    projectOperations.project(project).forUpdate().add(allow(Permission.CREATE).group(REGISTERED_USERS).ref("refs/heads/hidden")).update();
    PushOneCommit push1 = pushFactory.create(admin.newIdent(), testRepo);
    PushOneCommit.Result r1 = push1.to("refs/heads/master");
    r1.assertOkStatus();
    TagInput tag1 = new TagInput();
    tag1.ref = "v1.0";
    tag1.revision = r1.getCommit().getName();
    TagInfo result = tag(tag1.ref).create(tag1).get();
    assertThat(result.ref).isEqualTo(R_TAGS + tag1.ref);
    assertThat(result.revision).isEqualTo(tag1.revision);
    pushTo("refs/heads/hidden").assertOkStatus();
    PushOneCommit push2 = pushFactory.create(admin.newIdent(), testRepo);
    PushOneCommit.Result r2 = push2.to("refs/heads/hidden");
    r2.assertOkStatus();
    TagInput tag2 = new TagInput();
    tag2.ref = "v2.0";
    tag2.revision = r2.getCommit().getName();
    result = tag(tag2.ref).create(tag2).get();
    assertThat(result.ref).isEqualTo(R_TAGS + tag2.ref);
    assertThat(result.revision).isEqualTo(tag2.revision);
    List<TagInfo> tags = getTags().get();
    assertThat(tags).hasSize(2);
    assertThat(tags.get(0).ref).isEqualTo(R_TAGS + tag1.ref);
    assertThat(tags.get(0).revision).isEqualTo(tag1.revision);
    assertThat(tags.get(1).ref).isEqualTo(R_TAGS + tag2.ref);
    assertThat(tags.get(1).revision).isEqualTo(tag2.revision);
    projectOperations.project(project).forUpdate().add(block(Permission.READ).ref("refs/heads/hidden").group(REGISTERED_USERS)).update();
    tags = getTags().get();
    assertThat(tags).hasSize(1);
    assertThat(tags.get(0).ref).isEqualTo(R_TAGS + tag1.ref);
    assertThat(tags.get(0).revision).isEqualTo(tag1.revision);
}
Also used : TagInfo(com.google.gerrit.extensions.api.projects.TagInfo) TagInput(com.google.gerrit.extensions.api.projects.TagInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

TagInfo (com.google.gerrit.extensions.api.projects.TagInfo)16 TagInput (com.google.gerrit.extensions.api.projects.TagInput)10 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)9 Test (org.junit.Test)9 RevCommit (org.eclipse.jgit.revwalk.RevCommit)5 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)3 PersonIdent (org.eclipse.jgit.lib.PersonIdent)3 RevObject (org.eclipse.jgit.revwalk.RevObject)3 RevTag (org.eclipse.jgit.revwalk.RevTag)3 WebLinkInfo (com.google.gerrit.extensions.common.WebLinkInfo)2 IdString (com.google.gerrit.extensions.restapi.IdString)2 PermissionBackend (com.google.gerrit.server.permissions.PermissionBackend)2 Instant (java.time.Instant)2 ArrayList (java.util.ArrayList)2 Ref (org.eclipse.jgit.lib.Ref)2 Repository (org.eclipse.jgit.lib.Repository)2 RevWalk (org.eclipse.jgit.revwalk.RevWalk)2 ImmutableList (com.google.common.collect.ImmutableList)1 Project (com.google.gerrit.entities.Project)1 RefNames.isConfigRef (com.google.gerrit.entities.RefNames.isConfigRef)1