use of com.google.gerrit.extensions.api.projects.TagInfo in project gerrit by GerritCodeReview.
the class ListTags method createTagInfo.
public static TagInfo createTagInfo(PermissionBackend.ForRef perm, Ref ref, RevWalk rw) throws MissingObjectException, IOException {
RevObject object = rw.parseAny(ref.getObjectId());
boolean canDelete = perm.testOrFalse(RefPermission.DELETE);
if (object instanceof RevTag) {
// Annotated or signed tag
RevTag tag = (RevTag) object;
PersonIdent tagger = tag.getTaggerIdent();
return new TagInfo(ref.getName(), tag.getName(), tag.getObject().getName(), tag.getFullMessage().trim(), tagger != null ? CommonConverters.toGitPerson(tag.getTaggerIdent()) : null, canDelete);
}
// Lightweight tag
return new TagInfo(ref.getName(), ref.getObjectId().getName(), canDelete);
}
use of com.google.gerrit.extensions.api.projects.TagInfo in project gerrit by GerritCodeReview.
the class DeleteTagIT method assertDeleteSucceeds.
private void assertDeleteSucceeds() throws Exception {
TagInfo tagInfo = tag().get();
assertThat(tagInfo.canDelete).isTrue();
String tagRev = tagInfo.revision;
tag().delete();
eventRecorder.assertRefUpdatedEvents(project.get(), TAG, null, tagRev, tagRev, null);
assertThrows(ResourceNotFoundException.class, () -> tag().get());
}
use of com.google.gerrit.extensions.api.projects.TagInfo in project gerrit by GerritCodeReview.
the class GetBranchIT method getTagRef.
@Test
public void getTagRef() throws Exception {
// create a tag
TagInput input = new TagInput();
input.message = "My Tag";
input.revision = projectOperations.project(project).getHead("master").name();
TagInfo tagInfo = gApi.projects().name(project.get()).tag("my-tag").create(input).get();
// any user who can see the project, can see the tag
requestScopeOperations.setApiUser(user.id());
assertBranchFound(project, tagInfo.ref);
}
use of com.google.gerrit.extensions.api.projects.TagInfo in project gerrit by GerritCodeReview.
the class GetBranchIT method cannotGetTagRefThatPointsToNonVisibleBranch.
@Test
public void cannotGetTagRefThatPointsToNonVisibleBranch() throws Exception {
// create a tag
TagInput input = new TagInput();
input.message = "My Tag";
input.revision = projectOperations.project(project).getHead("master").name();
TagInfo tagInfo = gApi.projects().name(project.get()).tag("my-tag").create(input).get();
// block read access to the branch
projectOperations.project(project).forUpdate().add(block(Permission.READ).ref(RefNames.fullName("master")).group(ANONYMOUS_USERS)).update();
// if the user cannot see the project, the tag is not visible
requestScopeOperations.setApiUser(user.id());
assertBranchNotFound(project, tagInfo.ref);
}
use of com.google.gerrit.extensions.api.projects.TagInfo 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";
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> tag(input.ref).create(input));
assertThat(thrown).hasMessageThat().contains("tag \"" + R_TAGS + "test\" already exists");
}
Aggregations