Search in sources :

Example 16 with TagInput

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

the class ChangeIncludedInIT method includedInMergedChange.

@Test
public void includedInMergedChange() throws Exception {
    Result result = createChange();
    gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).review(ReviewInput.approve());
    gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().branches).containsExactly("master");
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().tags).isEmpty();
    projectOperations.project(project).forUpdate().add(allow(Permission.CREATE_TAG).ref(R_TAGS + "*").group(adminGroupUuid())).update();
    gApi.projects().name(project.get()).tag("test-tag").create(new TagInput());
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().tags).containsExactly("test-tag");
    createBranch(BranchNameKey.create(project, "test-branch"));
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().branches).containsExactly("master", "test-branch");
}
Also used : TagInput(com.google.gerrit.extensions.api.projects.TagInput) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 17 with TagInput

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

the class TagsIT method invalidTagName.

@Test
public void invalidTagName() throws Exception {
    grantTagPermissions();
    TagInput input = new TagInput();
    input.ref = "refs/heads/test";
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> tag(input.ref).create(input));
    assertThat(thrown).hasMessageThat().contains("invalid tag name \"" + input.ref + "\"");
}
Also used : BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) TagInput(com.google.gerrit.extensions.api.projects.TagInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 18 with TagInput

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

the class TagsIT method annotatedTag.

@Test
public void annotatedTag() throws Exception {
    grantTagPermissions();
    PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
    PushOneCommit.Result r = push.to("refs/heads/master");
    r.assertOkStatus();
    TagInput input = new TagInput();
    input.ref = "v1.0";
    input.revision = r.getCommit().getName();
    input.message = "annotation message";
    TagInfo result = tag(input.ref).create(input).get();
    assertThat(result.ref).isEqualTo(R_TAGS + input.ref);
    assertThat(result.object).isEqualTo(input.revision);
    assertThat(result.message).isEqualTo(input.message);
    assertThat(result.tagger.name).isEqualTo(admin.fullName());
    assertThat(result.tagger.email).isEqualTo(admin.email());
    assertThat(result.created).isEqualTo(result.tagger.date);
    eventRecorder.assertRefUpdatedEvents(project.get(), result.ref, null, result.revision);
    // A second tag pushed on the same ref should have the same ref
    TagInput input2 = new TagInput();
    input2.ref = "refs/tags/v2.0";
    input2.revision = input.revision;
    input2.message = "second annotation message";
    TagInfo result2 = tag(input2.ref).create(input2).get();
    assertThat(result2.ref).isEqualTo(input2.ref);
    assertThat(result2.object).isEqualTo(input2.revision);
    assertThat(result2.message).isEqualTo(input2.message);
    assertThat(result2.tagger.name).isEqualTo(admin.fullName());
    assertThat(result2.tagger.email).isEqualTo(admin.email());
    assertThat(result2.created).isEqualTo(result2.tagger.date);
    eventRecorder.assertRefUpdatedEvents(project.get(), result2.ref, null, result2.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)

Example 19 with TagInput

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

the class TagsIT method createTags.

private void createTags() throws Exception {
    grantTagPermissions();
    String revision = pushTo("refs/heads/master").getCommit().name();
    TagInput input = new TagInput();
    input.revision = revision;
    for (String tagname : testTags) {
        TagInfo result = tag(tagname).create(input).get();
        assertThat(result.revision).isEqualTo(input.revision);
        assertThat(result.ref).isEqualTo(R_TAGS + tagname);
    }
}
Also used : TagInfo(com.google.gerrit.extensions.api.projects.TagInfo) TagInput(com.google.gerrit.extensions.api.projects.TagInput)

Example 20 with TagInput

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

the class TagsIT method mismatchedInput.

@Test
public void mismatchedInput() throws Exception {
    TagInput input = new TagInput();
    input.ref = "test";
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> tag("TEST").create(input));
    assertThat(thrown).hasMessageThat().contains("ref must match URL");
}
Also used : BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) TagInput(com.google.gerrit.extensions.api.projects.TagInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

TagInput (com.google.gerrit.extensions.api.projects.TagInput)23 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)20 Test (org.junit.Test)20 TagInfo (com.google.gerrit.extensions.api.projects.TagInfo)10 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)6 AuthException (com.google.gerrit.extensions.restapi.AuthException)4 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)3 Result (com.google.gerrit.acceptance.PushOneCommit.Result)3 MethodNotAllowedException (com.google.gerrit.extensions.restapi.MethodNotAllowedException)3 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 PermissionBackend (com.google.gerrit.server.permissions.PermissionBackend)2 InvalidRevisionException (com.google.gerrit.server.project.RefUtil.InvalidRevisionException)2 IOException (java.io.IOException)2 Git (org.eclipse.jgit.api.Git)2 TagCommand (org.eclipse.jgit.api.TagCommand)2 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)2 ObjectId (org.eclipse.jgit.lib.ObjectId)2 Ref (org.eclipse.jgit.lib.Ref)2 Repository (org.eclipse.jgit.lib.Repository)2