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");
}
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 + "\"");
}
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);
}
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);
}
}
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");
}
Aggregations