camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject camel git commit: CAMEL-9386: Camel-git: Support credentials in clone operation
Date Thu, 03 Dec 2015 16:22:47 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x d35647f90 -> 85bbbb2f0


CAMEL-9386: Camel-git: Support credentials in clone operation


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/85bbbb2f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/85bbbb2f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/85bbbb2f

Branch: refs/heads/camel-2.16.x
Commit: 85bbbb2f01cedcc6887cec15ff4324efad25ff0d
Parents: d35647f
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Thu Dec 3 17:16:05 2015 +0100
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Thu Dec 3 17:22:08 2015 +0100

----------------------------------------------------------------------
 .../org/apache/camel/component/git/producer/GitProducer.java  | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/85bbbb2f/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
index 31d1bd4..3c225e8 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
@@ -154,7 +154,12 @@ public class GitProducer extends DefaultProducer {
         try {
             File localRepo = new File(endpoint.getLocalPath(), "");
             if (!localRepo.exists()) {
-                result = git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new
File(endpoint.getLocalPath(), "")).call();
+                if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword()))
{
+                    UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(),
endpoint.getPassword());
+                    result = git.cloneRepository().setCredentialsProvider(credentials).setURI(endpoint.getRemotePath()).setDirectory(new
File(endpoint.getLocalPath(), "")).call();
+                } else {
+                    result = git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new
File(endpoint.getLocalPath(), "")).call();
+                }
             } else {
                 throw new IllegalArgumentException("The local repository directory already
exists");
             }


Mime
View raw message