|
|
@ -140,12 +140,13 @@ public class GitRepository { |
|
|
|
|
|
|
|
|
public static GitRepository openOrClone(Path directory, RepositorySettings settings, boolean fetch) throws IOException, GitAPIException { |
|
|
public static GitRepository openOrClone(Path directory, RepositorySettings settings, boolean fetch) throws IOException, GitAPIException { |
|
|
GitRepository repository; |
|
|
GitRepository repository; |
|
|
if (Files.exists(directory)) { |
|
|
if (GitRepository.exists(directory.toString())) { |
|
|
repository = GitRepository.open(directory.toFile(), settings); |
|
|
repository = GitRepository.open(directory.toFile(), settings); |
|
|
if (fetch) { |
|
|
if (fetch) { |
|
|
repository.fetch(); |
|
|
repository.fetch(); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
FileUtils.deleteDirectory(directory.toFile()); |
|
|
Files.createDirectories(directory); |
|
|
Files.createDirectories(directory); |
|
|
if (settings.isLocalOnly()) { |
|
|
if (settings.isLocalOnly()) { |
|
|
repository = GitRepository.create(settings, directory.toFile()); |
|
|
repository = GitRepository.create(settings, directory.toFile()); |
|
|
@ -436,6 +437,10 @@ public class GitRepository { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean exists(String directory) { |
|
|
|
|
|
return Files.exists(Path.of(directory, ".git")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private <C extends GitCommand<T>, T> T execute(C command) throws GitAPIException { |
|
|
private <C extends GitCommand<T>, T> T execute(C command) throws GitAPIException { |
|
|
if (command instanceof TransportCommand transportCommand && authHandler != null) { |
|
|
if (command instanceof TransportCommand transportCommand && authHandler != null) { |
|
|
authHandler.configureCommand(transportCommand); |
|
|
authHandler.configureCommand(transportCommand); |
|
|
|