Search in sources :

Example 1 with RepositoryCommit

use of org.eclipse.egit.github.core.RepositoryCommit in project camel by apache.

the class CommitConsumer method poll.

@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();
}
Also used : Exchange(org.apache.camel.Exchange) RepositoryCommit(org.eclipse.egit.github.core.RepositoryCommit) Stack(java.util.Stack)

Example 2 with RepositoryCommit

use of org.eclipse.egit.github.core.RepositoryCommit in project camel by apache.

the class CommitConsumerTest method commitConsumerTest.

@Test
public void commitConsumerTest() throws Exception {
    mockResultEndpoint.expectedMessageCount(2);
    RepositoryCommit commit1 = commitService.addRepositoryCommit();
    RepositoryCommit commit2 = commitService.addRepositoryCommit();
    mockResultEndpoint.expectedBodiesReceivedInAnyOrder(commit1, commit2);
    Thread.sleep(1 * 1000);
    mockResultEndpoint.assertIsSatisfied();
}
Also used : RepositoryCommit(org.eclipse.egit.github.core.RepositoryCommit) Test(org.junit.Test)

Example 3 with RepositoryCommit

use of org.eclipse.egit.github.core.RepositoryCommit in project Bitocle by mthli.

the class CommitTask method doInBackground.

@Override
protected Boolean doInBackground(Void... params) {
    if (flag == Flag.REPO_COMMIT_FIRST || flag == Flag.REPO_COMMIT_REFRESH) {
        RepositoryId id = RepositoryId.create(repoItem.getOwner(), repoItem.getName());
        PageIterator<RepositoryCommit> pageIterator = commitService.pageCommits(id, 17);
        iterator = pageIterator.next().iterator();
    } else {
        RepositoryId id = RepositoryId.create(starItem.getOwner(), starItem.getName());
        PageIterator<RepositoryCommit> pageIterator = commitService.pageCommits(id, 17);
        iterator = pageIterator.next().iterator();
    }
    if (isCancelled()) {
        return false;
    }
    return true;
}
Also used : RepositoryId(org.eclipse.egit.github.core.RepositoryId) RepositoryCommit(org.eclipse.egit.github.core.RepositoryCommit)

Example 4 with RepositoryCommit

use of org.eclipse.egit.github.core.RepositoryCommit in project camel by apache.

the class MockCommitService method addRepositoryCommit.

public synchronized RepositoryCommit addRepositoryCommit() {
    User author = new User();
    // TODO change
    author.setEmail("someguy@gmail.com");
    author.setHtmlUrl("http://github/someguy");
    author.setLogin("someguy");
    RepositoryCommit rc = new RepositoryCommit();
    rc.setAuthor(author);
    rc.setSha(fakeSha.incrementAndGet() + "");
    LOG.debug("In MockCommitService added commit with sha " + rc.getSha());
    commitsList.add(rc);
    return rc;
}
Also used : User(org.eclipse.egit.github.core.User) RepositoryCommit(org.eclipse.egit.github.core.RepositoryCommit)

Example 5 with RepositoryCommit

use of org.eclipse.egit.github.core.RepositoryCommit in project Bitocle by mthli.

the class CommitTask method onPostExecute.

@Override
protected void onPostExecute(Boolean result) {
    if (result) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        list.clear();
        while (iterator.hasNext()) {
            RepositoryCommit commit = iterator.next();
            list.add(new CommitItem(commit.getCommit().getAuthor().getName(), format.format(commit.getCommit().getAuthor().getDate()), commit.getCommit().getMessage()));
        }
        if (list.size() <= 0) {
            fragment.setContentEmpty(true);
            fragment.setEmptyText(R.string.commit_empty_list);
            fragment.setContentShown(true);
        } else {
            fragment.setContentEmpty(false);
            adapter.notifyDataSetChanged();
            fragment.setContentShown(true);
        }
    } else {
        fragment.setContentEmpty(true);
        fragment.setEmptyText(R.string.commit_empty_error);
        fragment.setContentShown(true);
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) RepositoryCommit(org.eclipse.egit.github.core.RepositoryCommit)

Aggregations

RepositoryCommit (org.eclipse.egit.github.core.RepositoryCommit)5 SimpleDateFormat (java.text.SimpleDateFormat)1 Stack (java.util.Stack)1 Exchange (org.apache.camel.Exchange)1 RepositoryId (org.eclipse.egit.github.core.RepositoryId)1 User (org.eclipse.egit.github.core.User)1 Test (org.junit.Test)1