use of org.eclipse.jgit.revwalk.RevCommit in project gitiles by GerritCodeReview.
the class LogSoyData method renderStreaming.
public void renderStreaming(Paginator paginator, @Nullable String revision, Renderer renderer, Writer out, DateFormatter df) throws IOException {
renderer.newRenderer("gitiles.logEntriesHeader").setData(toHeaderSoyData(paginator, revision)).render(out);
out.flush();
SoyTofu.Renderer entryRenderer = renderer.newRenderer("gitiles.logEntryWrapper");
boolean renderedEntries = false;
for (RevCommit c : paginator) {
entryRenderer.setData(toEntrySoyData(paginator, c, df)).render(out);
out.flush();
renderedEntries = true;
}
if (!renderedEntries) {
renderer.newRenderer("gitiles.emptyLog").render(out);
}
renderer.newRenderer("gitiles.logEntriesFooter").setData(toFooterSoyData(paginator, revision)).render(out);
}
use of org.eclipse.jgit.revwalk.RevCommit in project camel by apache.
the class GitCommitConsumer method poll.
@Override
protected int poll() throws Exception {
int count = 0;
Iterable<RevCommit> commits = getGit().log().all().call();
for (RevCommit commit : commits) {
if (!commitsConsumed.contains(commit.getId())) {
Exchange e = getEndpoint().createExchange();
e.getOut().setBody(commit);
getProcessor().process(e);
commitsConsumed.add(commit.getId());
count++;
}
}
return count;
}
use of org.eclipse.jgit.revwalk.RevCommit in project camel by apache.
the class GitProducer method doCherryPick.
protected void doCherryPick(Exchange exchange, String operation) throws Exception {
CherryPickResult result = null;
String commitId = null;
try {
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_ID))) {
commitId = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_ID, String.class);
} else {
throw new IllegalArgumentException("Commit id must be specified to execute " + operation);
}
RevWalk walk = new RevWalk(repo);
ObjectId id = repo.resolve(commitId);
RevCommit commit = walk.parseCommit(id);
walk.dispose();
if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
}
result = git.cherryPick().include(commit).call();
} catch (Exception e) {
LOG.error("There was an error in Git " + operation + " operation");
throw e;
}
updateExchange(exchange, result);
}
use of org.eclipse.jgit.revwalk.RevCommit in project camel by apache.
the class GitTestSupport method validateGitLogs.
protected void validateGitLogs(Git git, String... messages) throws GitAPIException {
Iterable<RevCommit> logs = git.log().call();
int count = 0;
for (RevCommit rev : logs) {
assertEquals(messages[count], rev.getShortMessage());
count++;
}
assertEquals(messages.length, count);
}
use of org.eclipse.jgit.revwalk.RevCommit in project camel by apache.
the class GitConsumerTest method commitConsumerTest.
@Test
public void commitConsumerTest() throws Exception {
// Init
MockEndpoint mockResultCommit = getMockEndpoint("mock:result-commit");
mockResultCommit.expectedMessageCount(2);
Git git = getGitTestRepository();
File gitDir = new File(gitLocalRepo, ".git");
assertEquals(gitDir.exists(), true);
File fileToAdd = new File(gitLocalRepo, filenameToAdd);
fileToAdd.createNewFile();
git.add().addFilepattern(filenameToAdd).call();
Status status = git.status().call();
assertTrue(status.getAdded().contains(filenameToAdd));
git.commit().setMessage(commitMessage).call();
File fileToAdd1 = new File(gitLocalRepo, filenameBranchToAdd);
fileToAdd1.createNewFile();
git.add().addFilepattern(filenameBranchToAdd).call();
status = git.status().call();
assertTrue(status.getAdded().contains(filenameBranchToAdd));
git.commit().setMessage("Test test Commit").call();
Iterable<RevCommit> logs = git.log().call();
validateGitLogs(git, "Test test Commit", commitMessage);
// Test
mockResultCommit.assertIsSatisfied();
// Check
Exchange ex1 = mockResultCommit.getExchanges().get(0);
Exchange ex2 = mockResultCommit.getExchanges().get(1);
assertEquals(commitMessage, ex2.getOut().getBody(RevCommit.class).getShortMessage());
assertEquals("Test test Commit", ex1.getOut().getBody(RevCommit.class).getShortMessage());
git.close();
}
Aggregations