本文整理汇总了Java中org.eclipse.egit.github.core.Comment类的典型用法代码示例。如果您正苦于以下问题:Java Comment类的具体用法?Java Comment怎么用?Java Comment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Comment类属于org.eclipse.egit.github.core包,在下文中一共展示了Comment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editComment
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
@Whitelisted
public IssueCommentGroovyObject editComment(final long commentId, final String body) {
Objects.requireNonNull(body, "body is a required argument");
Comment comment = new Comment();
comment.setId(commentId);
comment.setBody(body);
try {
return new IssueCommentGroovyObject(
issueService.editComment(base, comment),
base,
issueService);
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
}
示例2: save
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
@SneakyThrows
public void save(PullRequestStatus commitStatus) {
String repoId = commitStatus.getRepoId();
String accessToken = commitStatus.getAccessToken();
if (accessToken == null) {
return;
}
PullRequestId pullRequestId = PullRequestId.of(RepositoryId.createFromId(repoId), commitStatus.getPullRequestId());
boolean hasSignedCla = commitStatus.isSuccess();
GitHubClient client = createClient(accessToken);
String claUserLogin = getGitHubClaUserLogin();
List<Comment> comments = getComments(pullRequestId, getIssueService());
boolean obviousFix = isObviousFix(pullRequestId, comments, claUserLogin, commitStatus.getPullRequestBody());
ContextCommitStatus status = createCommitStatusIfNecessary(pullRequestId, commitStatus, hasSignedCla, obviousFix, client);
createOrUpdatePullRequestComment(pullRequestId, commitStatus, hasSignedCla, obviousFix, status, comments, claUserLogin);
}
示例3: isObviousFix
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
/**
* Returns whether the pull-request is marked as obvious fix by having an issue/review comment stating it's an obvious fix.
* @param pullRequestId
* @param comments
* @param claUserLogin @return
* @param pullRequestBody
*/
private boolean isObviousFix(PullRequestId pullRequestId, List<Comment> comments, String claUserLogin, String pullRequestBody) {
if (hasObviousFix(pullRequestBody)) {
return true;
}
if (hasObviousFixComment(comments, claUserLogin)) {
return true;
}
if (hasObviousFixComment(getComments(pullRequestId, getPullRequestService()), claUserLogin)) {
return true;
}
return false;
}
示例4: createObviousFixCommentIfNecessary
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
/**
* Add a "disarming" comment.
* @param pullRequestId
* @param userMentionMarkdown
* @param issues
* @param claUserComments
* @throws IOException
*/
private void createObviousFixCommentIfNecessary(PullRequestId pullRequestId, String userMentionMarkdown,
IssueService issues, List<Comment> claUserComments) throws IOException {
// only if not already present and if a comment says "please sign the CLA"
if (claUserComments.stream().anyMatch(c -> c.getBody().contains(PLEASE_SIGN))
&& !claUserComments.stream().anyMatch(c -> c.getBody().contains(OBVIOUS_FIX_CLA_NOT_REQUIRED))) {
if (claUserComments.stream().anyMatch(c -> c.getBody().contains(THANK_YOU))) {
return;
}
String claNotRequiredBody = String.format("%s %s", userMentionMarkdown, OBVIOUS_FIX_CLA_NOT_REQUIRED);
issues.createComment(pullRequestId.getRepositoryId(), pullRequestId.getId(), claNotRequiredBody);
}
}
示例5: process
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
public void process(Exchange exchange) throws Exception {
Integer pullRequestNumber = exchange.getIn().getHeader("GitHubPullRequest", Integer.class);
Integer inResponseTo = exchange.getIn().getHeader("GitHubInResponseTo", Integer.class);
String text = exchange.getIn().getBody(String.class);
Comment response;
if (inResponseTo != null && inResponseTo > 0) {
response = pullRequestService.replyToComment(getRepository(), pullRequestNumber, inResponseTo, text);
} else {
// Otherwise, just comment on the pull request itself.
response = issueService.createComment(getRepository(), pullRequestNumber, text);
}
// support InOut
if (exchange.getPattern().isOutCapable()) {
// copy the header of in message to the out message
exchange.getOut().copyFrom(exchange.getIn());
exchange.getOut().setBody(response);
}
}
示例6: commentPullRequest
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
/**
* Adds comment to provided pull request.
*
* @param owner of repository
* @param pullRequest pull request owner
* @param comment message
* @return created remote comment
*/
public Comment commentPullRequest(String owner, String repositoryName, PullRequest pullRequest, String comment)
{
RepositoryContext bySlug = repositoryBySlug.get(getSlug(owner, repositoryName));
IssueService issueService = new IssueService(getGitHubClient(owner));
try
{
return issueService.createComment(bySlug.repository,
pullRequest.getIssueUrl().substring(pullRequest.getIssueUrl().lastIndexOf('/') + 1), comment);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
示例7: processPullRequestComments
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
/**
* Processes comments of a Pull Request.
*/
private void processPullRequestComments(Repository repository, PullRequest remotePullRequest,
RepositoryPullRequestMapping localPullRequest, Map<String, Participant> participantIndex)
{
updateCommentsCount(remotePullRequest, localPullRequest);
IssueService issueService = gitHubClientProvider.getIssueService(repository);
RepositoryId repositoryId = RepositoryId.createFromUrl(repository.getRepositoryUrl());
List<Comment> pullRequestComments;
try
{
pullRequestComments = issueService.getComments(repositoryId, remotePullRequest.getNumber());
}
catch (IOException e)
{
throw new RuntimeException(e);
}
remotePullRequest.setComments(Math.max(remotePullRequest.getComments(), pullRequestComments.size()));
for (Comment comment : pullRequestComments)
{
addParticipant(participantIndex, comment.getUser(), Participant.ROLE_PARTICIPANT);
}
}
示例8: testNoParticipants
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
@Test
public void testNoParticipants() throws IOException
{
when(issueService.getComments(any(IRepositoryIdProvider.class), anyInt())).thenReturn(Collections.<Comment>emptyList());
when(gitHubPullRequestService.getComments(any(IRepositoryIdProvider.class), anyInt())).thenReturn(Collections.<CommitComment>emptyList());
User user = mock(User.class);
when(user.getLogin()).thenReturn("user");
when(pullRequest.getUser()).thenReturn(user);
testedClass.processPullRequest(repository, pullRequest);
verify(pullRequestService).updatePullRequestParticipants(anyInt(), anyInt(), participantsIndexCaptor.capture());
assertEquals(participantsIndexCaptor.getValue().size(), 1);
Participant participant = participantsIndexCaptor.getValue().get("user");
assertParticipant(participant, "user");
}
示例9: close
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
@Override
public void close(String issueId) {
Validate.notNull(gitHubClient, "GitHub REST client must be specified.");
Comment comment = null;
try {
final Issue issue = getIssue(issueId);
issue.setState(IssueService.STATE_CLOSED);
comment =
this.issueService.createComment(this.gitHubGovernorConfiguration.getRepositoryUser(), this.gitHubGovernorConfiguration.getRepository(), issueId,
getClosingMessage());
this.issueService.editIssue(this.gitHubGovernorConfiguration.getRepositoryUser(), this.gitHubGovernorConfiguration.getRepository(), issue);
} catch (Exception e) {
if (comment != null) {
deleteComment(comment);
}
logger.warning(String.format("An exception has occured while closing the issue %s. Exception: %s", issueId, e.getMessage()));
}
}
示例10: immutability
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
@Test
public void immutability() {
List<TurboIssueEvent> events = stubEvents();
List<Comment> comments = stubComments();
IssueMetadata metadata = IssueMetadata.intermediate(events, comments, "", "");
assertEquals(3, metadata.getEvents().size());
assertEquals(3, metadata.getComments().size());
events.addAll(stubEvents());
comments.addAll(stubComments());
assertEquals(3, metadata.getEvents().size());
assertEquals(3, metadata.getComments().size());
metadata.getEvents().addAll(stubEvents());
metadata.getComments().addAll(stubComments());
assertEquals(3, metadata.getEvents().size());
assertEquals(3, metadata.getComments().size());
}
示例11: onActivityResult
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (RESULT_OK == resultCode && COMMENT_CREATE == requestCode
&& data != null) {
Comment comment = (Comment) data
.getSerializableExtra(EXTRA_COMMENT);
if (comments != null) {
comments.add(comment);
gist.setComments(gist.getComments() + 1);
updateList(gist, comments);
} else
refreshGist();
return;
}
super.onActivityResult(requestCode, resultCode, data);
}
示例12: run
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
@Override
public FullGist run(Account account) throws Exception {
Gist gist = store.refreshGist(id);
List<Comment> comments;
if (gist.getComments() > 0)
comments = service.getComments(id);
else
comments = Collections.emptyList();
for (Comment comment : comments) {
String formatted = HtmlUtils.format(comment.getBodyHtml())
.toString();
comment.setBodyHtml(formatted);
imageGetter.encode(comment, formatted);
}
return new FullGist(gist, service.isStarred(id), comments);
}
示例13: run
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
@Override
public FullIssue run(Account account) throws Exception {
Issue issue = store.refreshIssue(repositoryId, issueNumber);
bodyImageGetter.encode(issue.getId(), issue.getBodyHtml());
List<Comment> comments;
if (issue.getComments() > 0)
comments = service.getComments(repositoryId, issueNumber);
else
comments = Collections.emptyList();
for (Comment comment : comments) {
String formatted = HtmlUtils.format(comment.getBodyHtml())
.toString();
comment.setBodyHtml(formatted);
commentImageGetter.encode(comment.getId(), formatted);
}
return new FullIssue(issue, comments);
}
示例14: getComments
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
/**
* Get an issue's comments
*
* @param repository
* @param issueNumber
* @return list of comments
* @throws IOException
*/
private List<Comment> getComments(String repoId, String issueNumber)
throws IOException {
if (issueNumber == null)
throw new IllegalArgumentException("Issue number cannot be null"); //$NON-NLS-1$
if (issueNumber.length() == 0)
throw new IllegalArgumentException("Issue number cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(repoId);
uri.append(SEGMENT_ISSUES);
uri.append('/').append(issueNumber);
uri.append(SEGMENT_COMMENTS);
PagedRequest<Comment> request = createPagedRequest();
request.setUri(uri);
request.setType(new TypeToken<List<Comment>>() {
}.getType());
return getAll(request);
}
示例15: createComment
import org.eclipse.egit.github.core.Comment; //导入依赖的package包/类
/**
* Create comment on specified issue number
*
* @param repoId
* @param issueNumber
* @param comment
* @return created issue
* @throws IOException
*/
private Comment createComment(String repoId, String issueNumber,
String comment) throws IOException {
if (issueNumber == null)
throw new IllegalArgumentException("Issue number cannot be null"); //$NON-NLS-1$
if (issueNumber.length() == 0)
throw new IllegalArgumentException("Issue number cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(repoId);
uri.append(SEGMENT_ISSUES);
uri.append('/').append(issueNumber);
uri.append(SEGMENT_COMMENTS);
Map<String, String> params = new HashMap<String, String>(1, 1);
params.put(FIELD_BODY, comment);
return client.post(uri.toString(), params, Comment.class);
}