Search in sources :

Example 6 with TagInput

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

the class TagsIT method lightweightTag.

@Test
public void lightweightTag() throws Exception {
    grantTagPermissions();
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
    PushOneCommit.Result r = push.to("refs/heads/master");
    r.assertOkStatus();
    TagInput input = new TagInput();
    input.ref = "v1.0";
    input.revision = r.getCommit().getName();
    TagInfo result = tag(input.ref).create(input).get();
    assertThat(result.ref).isEqualTo(R_TAGS + input.ref);
    assertThat(result.revision).isEqualTo(input.revision);
    assertThat(result.canDelete).isTrue();
    input.ref = "refs/tags/v2.0";
    result = tag(input.ref).create(input).get();
    assertThat(result.ref).isEqualTo(input.ref);
    assertThat(result.revision).isEqualTo(input.revision);
    assertThat(result.canDelete).isTrue();
    setApiUser(user);
    result = tag(input.ref).get();
    assertThat(result.canDelete).isFalse();
    eventRecorder.assertRefUpdatedEvents(project.get(), result.ref, null, result.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 7 with TagInput

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

the class TagsIT method createExistingTag.

@Test
public void createExistingTag() throws Exception {
    grantTagPermissions();
    TagInput input = new TagInput();
    input.ref = "test";
    TagInfo result = tag(input.ref).create(input).get();
    assertThat(result.ref).isEqualTo(R_TAGS + "test");
    input.ref = "refs/tags/test";
    exception.expect(ResourceConflictException.class);
    exception.expectMessage("tag \"" + R_TAGS + "test\" already exists");
    tag(input.ref).create(input);
}
Also used : TagInfo(com.google.gerrit.extensions.api.projects.TagInfo) TagInput(com.google.gerrit.extensions.api.projects.TagInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 8 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();
    grantTagPermissions();
    gApi.projects().name(project.get()).tag("test-tag").create(new TagInput());
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().tags).containsExactly("test-tag");
    createBranch(new Branch.NameKey(project.get(), "test-branch"));
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().branches).containsExactly("master", "test-branch");
}
Also used : Branch(com.google.gerrit.reviewdb.client.Branch) TagInput(com.google.gerrit.extensions.api.projects.TagInput) Result(com.google.gerrit.acceptance.PushOneCommit.Result) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 9 with TagInput

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

the class TagsIT method invalidBaseRevision.

@Test
public void invalidBaseRevision() throws Exception {
    grantTagPermissions();
    TagInput input = new TagInput();
    input.ref = "test";
    input.revision = "abcdefg";
    exception.expect(BadRequestException.class);
    exception.expectMessage("Invalid base revision");
    tag(input.ref).create(input);
}
Also used : TagInput(com.google.gerrit.extensions.api.projects.TagInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 10 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)

Aggregations

TagInput (com.google.gerrit.extensions.api.projects.TagInput)15 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)13 Test (org.junit.Test)13 TagInfo (com.google.gerrit.extensions.api.projects.TagInfo)5 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)3 Result (com.google.gerrit.acceptance.PushOneCommit.Result)2 Branch (com.google.gerrit.reviewdb.client.Branch)2 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 MethodNotAllowedException (com.google.gerrit.extensions.restapi.MethodNotAllowedException)1 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 PermissionBackend (com.google.gerrit.server.permissions.PermissionBackend)1 InvalidRevisionException (com.google.gerrit.server.project.RefUtil.InvalidRevisionException)1 IOException (java.io.IOException)1 Git (org.eclipse.jgit.api.Git)1 TagCommand (org.eclipse.jgit.api.TagCommand)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 Ref (org.eclipse.jgit.lib.Ref)1 Repository (org.eclipse.jgit.lib.Repository)1