Search in sources :

Example 6 with TagInfo

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

the class TagsIT method emptyBaseRevision.

@Test
public void emptyBaseRevision() throws Exception {
    grantTagPermissions();
    // If revision is not specified, the tag is created based on HEAD, which points to master.
    RevCommit expectedRevision = projectOperations.project(project).getHead("master");
    TagInput input = new TagInput();
    input.ref = "test";
    input.revision = "";
    TagInfo result = tag(input.ref).create(input).get();
    assertThat(result.ref).isEqualTo(R_TAGS + input.ref);
    assertThat(result.revision).isEqualTo(expectedRevision.name());
}
Also used : TagInfo(com.google.gerrit.extensions.api.projects.TagInfo) TagInput(com.google.gerrit.extensions.api.projects.TagInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with TagInfo

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

the class TagsIT method lightweightTag.

@Test
public void lightweightTag() 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();
    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();
    assertThat(result.created.toInstant()).isEqualTo(instant(r));
    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();
    assertThat(result.created.toInstant()).isEqualTo(instant(r));
    requestScopeOperations.setApiUser(user.id());
    result = tag(input.ref).get();
    assertThat(result.canDelete).isNull();
    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 8 with TagInfo

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

the class TagsIT method noBaseRevision.

@Test
public void noBaseRevision() throws Exception {
    grantTagPermissions();
    // If revision is not specified, the tag is created based on HEAD, which points to master.
    RevCommit expectedRevision = projectOperations.project(project).getHead("master");
    TagInput input = new TagInput();
    input.ref = "test";
    input.revision = null;
    TagInfo result = tag(input.ref).create(input).get();
    assertThat(result.ref).isEqualTo(R_TAGS + input.ref);
    assertThat(result.revision).isEqualTo(expectedRevision.name());
}
Also used : TagInfo(com.google.gerrit.extensions.api.projects.TagInfo) TagInput(com.google.gerrit.extensions.api.projects.TagInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 9 with TagInfo

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

the class TagsIT method baseRevisionIsTrimmed.

@Test
public void baseRevisionIsTrimmed() throws Exception {
    grantTagPermissions();
    RevCommit revision = projectOperations.project(project).getHead("master");
    TagInput input = new TagInput();
    input.ref = "test";
    input.revision = "\t" + revision.name();
    TagInfo result = tag(input.ref).create(input).get();
    assertThat(result.ref).isEqualTo(R_TAGS + input.ref);
    assertThat(result.revision).isEqualTo(revision.name());
}
Also used : TagInfo(com.google.gerrit.extensions.api.projects.TagInfo) TagInput(com.google.gerrit.extensions.api.projects.TagInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 10 with TagInfo

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

the class TagsIT method assertTagList.

private void assertTagList(FluentIterable<String> expected, List<TagInfo> actual) throws Exception {
    assertThat(actual).hasSize(expected.size());
    for (int i = 0; i < expected.size(); i++) {
        TagInfo info = actual.get(i);
        assertThat(info.created).isNotNull();
        assertThat(info.ref).isEqualTo(R_TAGS + expected.get(i));
    }
}
Also used : TagInfo(com.google.gerrit.extensions.api.projects.TagInfo)

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