You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/11/05 13:21:51 UTC

[camel] 01/05: CAMEL-15812 - Camel-Git: Better structure for consumer returned object

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 921aa8aab61c08243d38cb14baa51d1c401f67cf
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 5 13:55:06 2020 +0100

    CAMEL-15812 - Camel-Git: Better structure for consumer returned object
---
 .../main/java/org/apache/camel/component/git/GitConstants.java   | 9 +++------
 .../apache/camel/component/git/consumer/GitCommitConsumer.java   | 7 ++++++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
index 27f8ca7..d3a4010 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
@@ -18,16 +18,13 @@ package org.apache.camel.component.git;
 
 public interface GitConstants {
     String GIT_OPERATION = "CamelGitOperation";
-
     String GIT_FILE_NAME = "CamelGitFilename";
-
     String GIT_COMMIT_MESSAGE = "CamelGitCommitMessage";
-
     String GIT_COMMIT_USERNAME = "CamelGitCommitUsername";
-
     String GIT_COMMIT_EMAIL = "CamelGitCommitEmail";
-
     String GIT_COMMIT_ID = "CamelGitCommitId";
-
     String GIT_ALLOW_EMPTY = "CamelGitAllowEmpty";
+    String GIT_COMMIT_AUTHOR_NAME = "CamelGitAuthorName";
+    String GIT_COMMIT_COMMITTER_NAME = "CamelGitCommiterName";
+    String GIT_COMMIT_TIME = "CamelGitCommitTime";    
 }
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
index 6719de5..06e203b 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
@@ -21,6 +21,7 @@ import java.util.List;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.component.git.GitConstants;
 import org.apache.camel.component.git.GitEndpoint;
 import org.apache.camel.util.ObjectHelper;
 import org.eclipse.jgit.revwalk.RevCommit;
@@ -46,7 +47,11 @@ public class GitCommitConsumer extends AbstractGitConsumer {
         for (RevCommit commit : commits) {
             if (!commitsConsumed.contains(commit.getId())) {
                 Exchange e = getEndpoint().createExchange();
-                e.getOut().setBody(commit);
+                e.getMessage().setBody(commit.getFullMessage());
+                e.getMessage().setHeader(GitConstants.GIT_COMMIT_ID, commit.getId());
+                e.getMessage().setHeader(GitConstants.GIT_COMMIT_AUTHOR_NAME, commit.getAuthorIdent().getName());
+                e.getMessage().setHeader(GitConstants.GIT_COMMIT_COMMITTER_NAME, commit.getCommitterIdent().getName());
+                e.getMessage().setHeader(GitConstants.GIT_COMMIT_TIME, commit.getCommitTime());
                 getProcessor().process(e);
                 commitsConsumed.add(commit.getId());
                 count++;