use of org.eclipse.jgit.transport.PushResult in project gerrit by GerritCodeReview.
the class PushTagIT method pushTag.
private String pushTag(TagType tagType, String tagName, boolean newCommit, boolean force, Status expectedStatus) throws Exception {
if (force) {
testRepo.reset(initialHead);
}
commit(user.getIdent(), "subject");
boolean createTag = tagName == null;
tagName = MoreObjects.firstNonNull(tagName, "v1_" + System.nanoTime());
switch(tagType) {
case LIGHTWEIGHT:
break;
case ANNOTATED:
if (createTag) {
createAnnotatedTag(testRepo, tagName, user.getIdent());
} else {
updateAnnotatedTag(testRepo, tagName, user.getIdent());
}
break;
default:
throw new IllegalStateException("unexpected tag type: " + tagType);
}
if (!newCommit) {
grant(project, "refs/for/refs/heads/master", Permission.SUBMIT, false, REGISTERED_USERS);
pushHead(testRepo, "refs/for/master%submit");
}
String tagRef = tagRef(tagName);
PushResult r = tagType == LIGHTWEIGHT ? pushHead(testRepo, tagRef, false, force) : GitUtil.pushTag(testRepo, tagName, !createTag);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(tagRef);
assertThat(refUpdate.getStatus()).named(tagType.name()).isEqualTo(expectedStatus);
return tagName;
}
Aggregations