本文整理汇总了Java中org.eclipse.egit.github.core.CommitComment类的典型用法代码示例。如果您正苦于以下问题:Java CommitComment类的具体用法?Java CommitComment怎么用?Java CommitComment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommitComment类属于org.eclipse.egit.github.core包,在下文中一共展示了CommitComment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPullRequestCommentProducer
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
@Test
public void testPullRequestCommentProducer() throws Exception {
PullRequest pullRequest = pullRequestService.addPullRequest("testPullRequestCommentProducer");
latestPullRequestId = pullRequest.getId();
Endpoint commentProducerEndpoint = getMandatoryEndpoint("direct:validPullRequest");
Exchange exchange = commentProducerEndpoint.createExchange();
String commentText = "Pushed this comment at " + new Date();
exchange.getIn().setBody(commentText);
template.send(commentProducerEndpoint, exchange);
Thread.sleep(1 * 1000);
// Verify that the mock pull request service received this comment.
List<CommitComment> commitComments = pullRequestService.getComments(null, (int) pullRequest.getId());
assertEquals(1, commitComments.size());
CommitComment commitComment = commitComments.get(0);
assertEquals("Commit IDs did not match ", Long.toString(pullRequest.getId()), commitComment.getCommitId());
assertEquals("Comment text did not match ", commentText, commitComment.getBodyText());
}
示例2: addComment
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
public CommitComment addComment(Long pullRequestId, String bodyText) {
CommitComment commitComment = new CommitComment();
User author = createAuthor();
commitComment.setUser(author);
commitComment.setCommitId("" + pullRequestId);
commitComment.setId(commentId.getAndIncrement());
commitComment.setBody(bodyText);
commitComment.setBodyText(bodyText);
List<CommitComment> comments;
if (allComments.containsKey(pullRequestId)) {
comments = allComments.get(pullRequestId);
} else {
comments = new ArrayList<CommitComment>();
}
comments.add(commitComment);
allComments.put(pullRequestId, comments);
return commitComment;
}
示例3: processPullRequestReviewComments
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
/**
* Processes review comments of a Pull Request.
*/
private void processPullRequestReviewComments(Repository repository, PullRequest remotePullRequest,
RepositoryPullRequestMapping localPullRequest, Map<String, Participant> participantIndex)
{
updateCommentsCount(remotePullRequest, localPullRequest);
PullRequestService pullRequestService = gitHubClientProvider.getPullRequestService(repository);
RepositoryId repositoryId = RepositoryId.createFromUrl(repository.getRepositoryUrl());
List<CommitComment> pullRequestReviewComments;
try
{
pullRequestReviewComments = pullRequestService.getComments(repositoryId, remotePullRequest.getNumber());
}
catch (IOException e)
{
throw new RuntimeException(e);
}
remotePullRequest.setReviewComments(Math.max(remotePullRequest.getReviewComments(), pullRequestReviewComments.size()));
for (CommitComment comment : pullRequestReviewComments)
{
addParticipant(participantIndex, comment.getUser(), Participant.ROLE_PARTICIPANT);
}
}
示例4: testNoParticipants
import org.eclipse.egit.github.core.CommitComment; //导入依赖的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");
}
示例5: getItemId
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
@Override
public long getItemId(int position) {
switch (getItemViewType(position)) {
case TYPE_FILE_HEADER:
String sha = ((CommitFile) getItem(position)).getSha();
if (!TextUtils.isEmpty(sha))
return sha.hashCode();
else
return super.getItemId(position);
case TYPE_COMMENT:
case TYPE_LINE_COMMENT:
return ((CommitComment) getItem(position)).getId();
default:
return super.getItemId(position);
}
}
示例6: add
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
@Override
public boolean add(final CommitComment comment) {
String path = comment.getPath();
if (TextUtils.isEmpty(path))
return super.add(comment);
else {
boolean added = false;
for (FullCommitFile file : files)
if (path.equals(file.getFile().getFilename())) {
file.add(comment);
added = true;
break;
}
if (!added)
added = super.add(comment);
return added;
}
}
示例7: run
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
@Override
protected FullCommit run(Account account) throws Exception {
RepositoryCommit commit = store.refreshCommit(repository, id);
Commit rawCommit = commit.getCommit();
if (rawCommit != null && rawCommit.getCommentCount() > 0) {
List<CommitComment> comments = service.getComments(repository,
commit.getSha());
for (CommitComment comment : comments) {
String formatted = HtmlUtils.format(comment.getBodyHtml())
.toString();
comment.setBodyHtml(formatted);
imageGetter.encode(comment, formatted);
}
return new FullCommit(commit, comments);
} else
return new FullCommit(commit);
}
示例8: removeIssuesAlreadyReported
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
private void removeIssuesAlreadyReported(Multimap<String, Issue> fileViolations,
Map<String, LinePositioner> linePositioners) throws MojoExecutionException {
List<CommitComment> currentComments;
try {
currentComments = pullRequestService.getComments( repository, pullRequestId );
} catch (IOException e) {
throw new MojoExecutionException( "Unable to retrieve comments", e );
}
for (CommitComment comment : currentComments) {
Iterator<Issue> issues = fileViolations.get(
comment.getPath() ).iterator();
while (issues.hasNext()) {
Issue issue = (Issue) issues.next();
Integer line = issue.line();
if (line == null)
line = 1;
int position = linePositioners.get( comment.getPath() )
.toPostion( line );
if (position == comment.getPosition()
&& issue.message().equals( comment.getBody() ))
issues.remove();
}
}
}
示例9: pageComments
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
/**
* Page comments on commit with given SHA-1
*
* @param repository
* @param sha
* @param start
* @param size
* @return page iterator over comments
*/
public PageIterator<CommitComment> pageComments(
IRepositoryIdProvider repository, String sha, int start, int size) {
String id = getId(repository);
if (sha == null)
throw new IllegalArgumentException("Sha cannot be null"); //$NON-NLS-1$
if (sha.length() == 0)
throw new IllegalArgumentException("Sha cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_COMMITS);
uri.append('/').append(sha);
uri.append(SEGMENT_COMMENTS);
PagedRequest<CommitComment> request = createPagedRequest(start, size);
request.setUri(uri);
request.setType(new TypeToken<List<CommitComment>>() {
}.getType());
return createPageIterator(request);
}
示例10: addComment
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
/**
* Add comment to given commit
*
* @param repository
* @param sha
* @param comment
* @return created comment
* @throws IOException
*/
public CommitComment addComment(IRepositoryIdProvider repository,
String sha, CommitComment comment) throws IOException {
String id = getId(repository);
if (sha == null)
throw new IllegalArgumentException("Sha cannot be null"); //$NON-NLS-1$
if (sha.length() == 0)
throw new IllegalArgumentException("Sha cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_COMMITS);
uri.append('/').append(sha);
uri.append(SEGMENT_COMMENTS);
return client.post(uri.toString(), comment, CommitComment.class);
}
示例11: pullRequestCommentTest
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
@Test
public void pullRequestCommentTest() throws Exception {
PullRequest pr1 = pullRequestService.addPullRequest("First add");
PullRequest pr2 = pullRequestService.addPullRequest("Second");
CommitComment commitComment1 = pullRequestService.addComment(pr1.getId(), "First comment");
CommitComment commitComment2 = pullRequestService.addComment(pr2.getId(), "Second comment");
mockResultEndpoint.expectedBodiesReceivedInAnyOrder(commitComment1, commitComment2);
Thread.sleep(1 * 1000); // TODO do I need this?
mockResultEndpoint.assertIsSatisfied();
}
示例12: getComments
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
public List<CommitComment> getComments(IRepositoryIdProvider repository, int pullRequestId) {
Long id = new Long(pullRequestId);
if (allComments.containsKey(id)) {
List<CommitComment> comments = allComments.get(id);
return comments;
} else {
return emptyComments;
}
}
示例13: process
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void process(Repository repository, Event event, boolean isSoftSync, String[] synchronizationTags, GitHubEventContext context)
{
PullRequestReviewCommentPayload payload = getPayload(event);
CommitComment commitComment = payload.getComment();
PullRequest pullRequest = getPullRequestByComment(repository, commitComment);
if (pullRequest == null)
{
return;
}
context.savePullRequest(pullRequest);
}
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:17,代码来源:PullRequestReviewCommentPayloadGitHubEventProcessor.java
示例14: addItem
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
/**
* Add file to adapter
*
* @param file
*/
public void addItem(final FullCommitFile file) {
addItem(TYPE_FILE_HEADER, file.getFile());
List<CharSequence> lines = diffStyler.get(file.getFile().getFilename());
int number = 0;
for (CharSequence line : lines) {
addItem(TYPE_FILE_LINE, line);
for (CommitComment comment : file.get(number))
addItem(TYPE_LINE_COMMENT, comment);
number++;
}
}
示例15: CreateCommentTask
import org.eclipse.egit.github.core.CommitComment; //导入依赖的package包/类
/**
* Create task to create a comment
*
* @param activity
* @param repository
* @param commit
* @param comment
*/
protected CreateCommentTask(final Activity activity,
final IRepositoryIdProvider repository, final String commit,
final CommitComment comment) {
super(activity);
this.repository = repository;
this.commit = commit;
this.comment = comment;
}