本文整理汇总了Java中org.eclipse.egit.github.core.RepositoryCommit类的典型用法代码示例。如果您正苦于以下问题:Java RepositoryCommit类的具体用法?Java RepositoryCommit怎么用?Java RepositoryCommit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RepositoryCommit类属于org.eclipse.egit.github.core包,在下文中一共展示了RepositoryCommit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importCommits
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
public void importCommits(ProjectEvent projectEvent) throws IOException {
Project project = projectService.getProject(projectEvent.getProjectId());
Assert.notNull(project, "Could not find project with the provided id");
// Get GitHub repository commits
RepositoryId repositoryId = new RepositoryId(project.getOwner(), project.getName());
List<RepositoryCommit> repositoryCommits = gitTemplate.commitService().getCommits(repositoryId);
Flux<Commit> commits;
commits = Flux.fromStream(repositoryCommits.stream()).map(c -> {
try {
log.info("Importing commit: " + repositoryId.getName() + " -> " + c.getSha());
return gitTemplate.commitService().getCommit(repositoryId, c.getSha());
} catch (IOException e) {
throw new RuntimeException("Could not get commit", e);
}
}).filter(a -> a.getFiles() != null && a.getFiles().size() < 10)
.map(a -> new Commit(a.getFiles().stream()
.map(f -> new File(f.getFilename())).collect(Collectors.toList()),
a.getCommit().getCommitter().getName(),
a.getCommit().getCommitter().getDate().getTime()))
.sort(Comparator.comparing(Commit::getCommitDate));
commits.subscribe(commit -> saveCommits(project, commit));
}
示例2: poll
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
@Override
protected int poll() throws Exception {
List<RepositoryCommit> commits = commitService.getCommits(getRepository());
// In the end, we want tags oldest to newest.
Stack<RepositoryCommit> newCommits = new Stack<RepositoryCommit>();
for (RepositoryCommit commit : commits) {
if (!commitHashes.contains(commit.getSha())) {
newCommits.push(commit);
commitHashes.add(commit.getSha());
}
}
while (!newCommits.empty()) {
RepositoryCommit newCommit = newCommits.pop();
Exchange e = getEndpoint().createExchange();
e.getIn().setBody(newCommit);
getProcessor().process(e);
}
return newCommits.size();
}
示例3: getFileDetails
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
@Override
public ChangesetFileDetailsEnvelope getFileDetails(Repository repository, Changeset changeset)
{
CommitService commitService = githubClientProvider.getCommitService(repository);
RepositoryId repositoryId = RepositoryId.create(repository.getOrgName(), repository.getSlug());
// Workaround for BBC-455
checkRequestRateLimit(commitService.getClient());
try
{
RepositoryCommit commit = commitService.getCommit(repositoryId, changeset.getNode());
return new ChangesetFileDetailsEnvelope(GithubChangesetFactory.transformToFileDetails(commit.getFiles()), commit.getFiles().size());
}
catch (IOException e)
{
throw new SourceControlException("could not get result", e);
}
}
示例4: gettingDetailChangeset_ShouldSendGETRequestToGithub_AndParseJsonResult
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
@Test
public void gettingDetailChangeset_ShouldSendGETRequestToGithub_AndParseJsonResult()
throws ResponseException, IOException
{
when(repository.getSlug()).thenReturn("SLUG");
when(repository.getOrgName()).thenReturn("ORG");
RepositoryCommit repositoryCommit = mock(RepositoryCommit.class);
when(commitService.getCommit(Matchers.<IRepositoryIdProvider>anyObject(), anyString())).thenReturn(repositoryCommit);
Commit commit = mock(Commit.class);
when(repositoryCommit.getCommit()).thenReturn(commit);
when(commit.getMessage()).thenReturn("ABC-123 fix");
Changeset detailChangeset = communicator.getChangeset(repository, "abcde");
verify(commitService).getCommit(Matchers.<IRepositoryIdProvider>anyObject(), anyString());
assertThat(detailChangeset.getMessage()).isEqualTo("ABC-123 fix");
}
示例5: testCommit
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
@Test
public void testCommit() throws IOException
{
when(repositoryPullRequestDao.findRequestByRemoteId(eq(repository), anyLong())).thenReturn(null);
RepositoryCommit repositoryCommit = mockCommit("aaa");
when(gitHubPullRequestService.getCommits(any(IRepositoryIdProvider.class), anyInt())).thenReturn(Arrays.asList(repositoryCommit));
final String issueKey = "TST-1";
final ImmutableSet<String> issueKeys = ImmutableSet.of(issueKey);
when(repositoryPullRequestDao.getIssueKeys(anyInt(), anyInt())).thenReturn(issueKeys);
testedClass.processPullRequest(repository, pullRequest);
verify(repositoryPullRequestDao).saveCommit(eq(repository), saveCommitCaptor.capture());
assertEquals(saveCommitCaptor.getValue().get(RepositoryCommitMapping.NODE), "aaa");
ArgumentCaptor<Object> eventCaptor = ArgumentCaptor.forClass(Object.class);
verify(notificationService, times(1)).broadcast(eventCaptor.capture());
DevSummaryChangedEvent firstEvent = (DevSummaryChangedEvent) eventCaptor.getValue();
assertThat(firstEvent.getIssueKeys(), contains(new String[] { issueKey }));
}
示例6: testUpdateCommits
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
@Test
public void testUpdateCommits() throws IOException
{
when(repositoryPullRequestDao.findRequestByRemoteId(eq(repository), anyLong())).thenReturn(null);
RepositoryCommitMapping commitMapping = mock(RepositoryCommitMapping.class);
when(commitMapping.getNode()).thenReturn("original");
when(pullRequestMapping.getCommits()).thenReturn(new RepositoryCommitMapping[] { commitMapping });
target.setCommits(new RepositoryCommitMapping[] { commitMapping });
RepositoryCommit repositoryCommit = mockCommit("aaa");
when(gitHubPullRequestService.getCommits(any(IRepositoryIdProvider.class), anyInt())).thenReturn(Arrays.asList(repositoryCommit));
testedClass.processPullRequest(repository, pullRequest);
verify(repositoryPullRequestDao).saveCommit(eq(repository), saveCommitCaptor.capture());
assertEquals(saveCommitCaptor.getValue().get(RepositoryCommitMapping.NODE), "aaa");
verify(repositoryPullRequestDao).unlinkCommits(eq(repository), eq(target), argThat(IsIterableContainingInAnyOrder.containsInAnyOrder(commitMapping)));
verify(repositoryPullRequestDao).removeCommits(argThat(IsIterableContainingInAnyOrder.containsInAnyOrder(commitMapping)));
verify(notificationService, times(1)).broadcast(anyObject());
}
示例7: testUpdateCommitNoChange
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
@Test
public void testUpdateCommitNoChange() throws IOException
{
RepositoryCommitMapping commitMapping = mock(RepositoryCommitMapping.class);
when(commitMapping.getNode()).thenReturn("original");
when(pullRequestMapping.getCommits()).thenReturn(new RepositoryCommitMapping[] { commitMapping });
target.setCommits(new RepositoryCommitMapping[] { commitMapping });
RepositoryCommit repositoryCommit = mockCommit("aaa");
when(gitHubPullRequestService.getCommits(any(IRepositoryIdProvider.class), anyInt())).thenReturn(Arrays.asList(repositoryCommit));
testedClass.processPullRequest(repository, pullRequest);
verify(repositoryPullRequestDao, never()).saveCommit(eq(repository), anyMap());
verify(repositoryPullRequestDao, never()).unlinkCommits(eq(repository), eq(pullRequestMapping), any(Iterable.class));
verify(repositoryPullRequestDao, never()).removeCommits(any(Iterable.class));
}
示例8: testUpdateCommitRetargeted
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
@Test
public void testUpdateCommitRetargeted() throws IOException
{
final PullRequestMarker destination = mockRef("destinationBranch2");
when(pullRequest.getBase()).thenReturn(destination);
RepositoryCommitMapping commitMapping = mock(RepositoryCommitMapping.class);
when(commitMapping.getNode()).thenReturn("original");
when(pullRequestMapping.getCommits()).thenReturn(new RepositoryCommitMapping[] { commitMapping });
target.setCommits(new RepositoryCommitMapping[] { commitMapping });
RepositoryCommit repositoryCommit = mockCommit("aaa");
when(gitHubPullRequestService.getCommits(any(IRepositoryIdProvider.class), anyInt())).thenReturn(Arrays.asList(repositoryCommit));
testedClass.processPullRequest(repository, pullRequest);
verify(repositoryPullRequestDao).saveCommit(eq(repository), saveCommitCaptor.capture());
assertEquals(saveCommitCaptor.getValue().get(RepositoryCommitMapping.NODE), "aaa");
verify(repositoryPullRequestDao).unlinkCommits(eq(repository), eq(target), argThat(IsIterableContainingInAnyOrder.containsInAnyOrder(commitMapping)));
verify(repositoryPullRequestDao).removeCommits(argThat(IsIterableContainingInAnyOrder.containsInAnyOrder(commitMapping)));
}
示例9: testUpdateCommitStatusChanged
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
@Test
public void testUpdateCommitStatusChanged() throws IOException
{
when(pullRequest.getState()).thenReturn("closed");
RepositoryCommitMapping commitMapping = mock(RepositoryCommitMapping.class);
when(commitMapping.getNode()).thenReturn("original");
when(pullRequestMapping.getCommits()).thenReturn(new RepositoryCommitMapping[] { commitMapping });
target.setCommits(new RepositoryCommitMapping[] { commitMapping });
RepositoryCommit repositoryCommit = mockCommit("aaa");
when(gitHubPullRequestService.getCommits(any(IRepositoryIdProvider.class), anyInt())).thenReturn(Arrays.asList(repositoryCommit));
testedClass.processPullRequest(repository, pullRequest);
verify(repositoryPullRequestDao).saveCommit(eq(repository), saveCommitCaptor.capture());
assertEquals(saveCommitCaptor.getValue().get(RepositoryCommitMapping.NODE), "aaa");
verify(repositoryPullRequestDao).unlinkCommits(eq(repository), eq(target), argThat(IsIterableContainingInAnyOrder.containsInAnyOrder(commitMapping)));
verify(repositoryPullRequestDao).removeCommits(argThat(IsIterableContainingInAnyOrder.containsInAnyOrder(commitMapping)));
}
示例10: openCommit
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
private void openCommit(final RepositoryCommit commit) {
if (compare != null) {
int commitPosition = 0;
Collection<RepositoryCommit> commits = compare.getCommits();
for (RepositoryCommit candidate : commits)
if (commit == candidate)
break;
else
commitPosition++;
if (commitPosition < commits.size())
startActivity(CommitViewActivity.createIntent(repository,
commitPosition, commits));
} else
startActivity(CommitViewActivity.createIntent(repository,
commit.getSha()));
}
示例11: onCreateLoader
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
@Override
public Loader<List<RepositoryCommit>> onCreateLoader(int id, Bundle bundle) {
final ThrowableLoader<List<RepositoryCommit>> parentLoader = (ThrowableLoader<List<RepositoryCommit>>) super
.onCreateLoader(id, bundle);
return new ThrowableLoader<List<RepositoryCommit>>(getActivity(), items) {
@Override
public List<RepositoryCommit> loadData() throws Exception {
if (TextUtils.isEmpty(ref)) {
String defaultBranch = repository.getMasterBranch();
if (TextUtils.isEmpty(defaultBranch)) {
defaultBranch = repoService.getRepository(repository)
.getMasterBranch();
if (TextUtils.isEmpty(defaultBranch))
defaultBranch = "master";
}
ref = defaultBranch;
}
return parentLoader.loadData();
}
};
}
示例12: addCommit
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
/**
* Add commit to store
*
* @param repo
* @param commit
* @return commit
*/
public RepositoryCommit addCommit(IRepositoryIdProvider repo,
RepositoryCommit commit) {
RepositoryCommit current = getCommit(repo, commit.getSha());
if (current != null) {
current.setAuthor(commit.getAuthor());
current.setCommit(commit.getCommit());
current.setCommitter(commit.getCommitter());
current.setFiles(commit.getFiles());
current.setParents(commit.getParents());
current.setSha(commit.getSha());
current.setStats(commit.getStats());
current.setUrl(commit.getUrl());
return current;
} else {
String repoId = repo.generateId();
ItemReferences<RepositoryCommit> repoCommits = commits.get(repoId);
if (repoCommits == null) {
repoCommits = new ItemReferences<RepositoryCommit>();
commits.put(repoId, repoCommits);
}
repoCommits.put(commit.getSha(), commit);
return commit;
}
}
示例13: run
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的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);
}
示例14: pageCommits
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
/**
* Page commits in given repository
*
* @param repository
* @param sha
* @param path
* @param size
* @return page iterator
*/
public PageIterator<RepositoryCommit> pageCommits(
IRepositoryIdProvider repository, String sha, String path, int size) {
String id = getId(repository);
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_COMMITS);
PagedRequest<RepositoryCommit> request = createPagedRequest(PAGE_FIRST,
size);
request.setUri(uri);
request.setType(new TypeToken<List<RepositoryCommit>>() {
}.getType());
if (sha != null || path != null) {
Map<String, String> params = new HashMap<String, String>();
if (sha != null)
params.put("sha", sha); //$NON-NLS-1$
if (path != null)
params.put("path", path); //$NON-NLS-1$
request.setParams(params);
}
return createPageIterator(request);
}
示例15: getCommit
import org.eclipse.egit.github.core.RepositoryCommit; //导入依赖的package包/类
/**
* Get commit with given SHA-1 from given repository
*
* @param repository
* @param sha
* @return repository commit
* @throws IOException
*/
public RepositoryCommit getCommit(IRepositoryIdProvider repository,
String sha) 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);
GitHubRequest request = createRequest();
request.setUri(uri);
request.setType(RepositoryCommit.class);
return (RepositoryCommit) client.get(request).getBody();
}