apupier commented on code in PR #21581:
URL: https://github.com/apache/camel/pull/21581#discussion_r2841616951


##########
components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java:
##########
@@ -204,30 +204,26 @@ protected void doClone(String operation) throws 
GitAPIException {
             throw new IllegalArgumentException("Local path must specified to 
execute " + operation);
         }
         try {
-            File localRepo = new File(endpoint.getLocalPath(), "");
+            File localRepo = new File(endpoint.getLocalPath());
             if (!localRepo.exists()) {
-                if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && 
ObjectHelper.isNotEmpty(endpoint.getPassword())) {
-                    UsernamePasswordCredentialsProvider credentials
-                            = new 
UsernamePasswordCredentialsProvider(endpoint.getUsername(), 
endpoint.getPassword());
-                    if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
-                        result = 
Git.cloneRepository().setCredentialsProvider(credentials).setURI(endpoint.getRemotePath())
-                                .setDirectory(new 
File(endpoint.getLocalPath(), ""))
-                                .call();
-                    } else {
-                        result = 
Git.cloneRepository().setCredentialsProvider(credentials).setURI(endpoint.getRemotePath())
-                                .setDirectory(new 
File(endpoint.getLocalPath(), ""))
-                                .setBranch(endpoint.getBranchName()).call();
-                    }
-                } else {
-                    if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
-                        result = 
Git.cloneRepository().setURI(endpoint.getRemotePath())
-                                .setDirectory(new 
File(endpoint.getLocalPath(), "")).call();
-                    } else {
-                        result = 
Git.cloneRepository().setURI(endpoint.getRemotePath())
-                                .setDirectory(new 
File(endpoint.getLocalPath(), "")).setBranch(endpoint.getBranchName())
-                                .call();
-                    }
+                var cloneCommand = Git.cloneRepository()
+                        .setURI(endpoint.getRemotePath())
+                        .setDirectory(new File(endpoint.getLocalPath()));

Review Comment:
   Why not reusing directly localRepo variable?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to