|
5 | 5 | import java.util.List; |
6 | 6 | import java.util.Set; |
7 | 7 |
|
8 | | -import org.eclipse.jgit.api.CheckoutCommand; |
9 | | -import org.eclipse.jgit.api.FetchCommand; |
10 | | -import org.eclipse.jgit.api.Git; |
11 | | -import org.eclipse.jgit.api.InitCommand; |
| 8 | +import org.eclipse.jgit.api.*; |
12 | 9 | import org.eclipse.jgit.api.ListBranchCommand.ListMode; |
13 | | -import org.eclipse.jgit.api.MergeCommand; |
14 | | -import org.eclipse.jgit.api.MergeResult; |
15 | | -import org.eclipse.jgit.api.PullCommand; |
16 | | -import org.eclipse.jgit.api.RemoteAddCommand; |
17 | | -import org.eclipse.jgit.api.RemoteRemoveCommand; |
18 | 10 | import org.eclipse.jgit.api.ResetCommand.ResetType; |
19 | | -import org.eclipse.jgit.api.Status; |
20 | 11 | import org.eclipse.jgit.dircache.DirCache; |
21 | 12 | import org.eclipse.jgit.lib.Constants; |
22 | 13 | import org.eclipse.jgit.lib.Ref; |
@@ -370,10 +361,17 @@ public static void gitInit(String dirPath) throws ExceptionDBGit { |
370 | 361 | } |
371 | 362 | } |
372 | 363 |
|
373 | | - public static void gitClone(String link, String remoteName) throws ExceptionDBGit { |
| 364 | + public static void gitClone(String link, String remoteName, File directory) throws ExceptionDBGit { |
374 | 365 | try { |
375 | | - Git.cloneRepository().setURI(link).setCredentialsProvider(getCredentialsProvider(link)) |
376 | | - .setRemote(remoteName.equals("") ? Constants.DEFAULT_REMOTE_NAME : remoteName).call(); |
| 366 | + String actualRemoteName = remoteName.equals("") ? Constants.DEFAULT_REMOTE_NAME : remoteName; |
| 367 | + CredentialsProvider cp = getCredentialsProvider(link); |
| 368 | + CloneCommand cc = Git.cloneRepository() |
| 369 | + .setURI(link) |
| 370 | + .setRemote(actualRemoteName) |
| 371 | + .setCredentialsProvider(cp) |
| 372 | + .setDirectory(directory); |
| 373 | + |
| 374 | + cc.call(); |
377 | 375 |
|
378 | 376 | ConsoleWriter.println(DBGitLang.getInstance().getValue("general", "clone", "cloned")); |
379 | 377 |
|
@@ -499,6 +497,10 @@ private static CredentialsProvider getCredentialsProvider(String link) throws Ex |
499 | 497 | |
500 | 498 | ConsoleWriter.detailsPrintLn("login: " + login); |
501 | 499 | ConsoleWriter.detailsPrintLn("pass: " + pass);*/ |
| 500 | + if(uri.getUser() == null) { |
| 501 | + ConsoleWriter.detailsPrintlnRed(DBGitLang.getInstance().getValue("errors", "gitLoginNotFound")); |
| 502 | + return null; |
| 503 | + } |
502 | 504 | return new UsernamePasswordCredentialsProvider(uri.getUser(), uri.getPass()); |
503 | 505 | } catch (Exception e) { |
504 | 506 | throw new ExceptionDBGit(e); |
|
0 commit comments