// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableGitRepository.java
// public interface CloseableGitRepository extends GitRepository, AutoCloseable {
// 
//     @Override
//     void close();
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepositoryFactory.java
// public interface GitRepositoryFactory {
// 
//     CloseableGitRepository getRepository(File dir);
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
// 
//     private IOUtils() { }
// 
//     public static <T> T unchecked(IOCallable<T> callable) {
//         try {
//             return callable.call();
//         } catch (IOException ex) {
//             throw new RuntimeIOException(ex);
//         }
//     }
// 
//     public static void unchecked(IORunnable runnable) {
//         try {
//             runnable.run();
//         } catch (IOException ex) {
//             throw new RuntimeIOException(ex);
//         }
//     }
// }


import java.io.File;
import java.io.IOException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableGitRepository;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepositoryFactory;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;




public class JGitRepositoryFactory implements GitRepositoryFactory {

    private final Logger logger = LoggerFactory.getLogger(JGitRepositoryFactory.class);


    @Override
    public CloseableGitRepository getRepository(File dir) {
        return IOUtils.unchecked(() -> doGetRepository(dir));
    }


    private CloseableGitRepository doGetRepository(File dir) throws IOException {

// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableGitRepository.java
// public interface CloseableGitRepository extends GitRepository, AutoCloseable {
// 
//     @Override
//     void close();
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepositoryFactory.java
// public interface GitRepositoryFactory {
// 
//     CloseableGitRepository getRepository(File dir);
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
// 
//     private IOUtils() { }
// 
//     public static <T> T unchecked(IOCallable<T> callable) {
//         try {
//             return callable.call();
//         } catch (IOException ex) {
//             throw new RuntimeIOException(ex);
//         }
//     }
// 
//     public static void unchecked(IORunnable runnable) {
//         try {
//             runnable.run();
//         } catch (IOException ex) {
//             throw new RuntimeIOException(ex);
//         }
//     }
// }


// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitRepositoryFactory.java
import java.io.File;
import java.io.IOException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableGitRepository;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepositoryFactory;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;

package org.unbrokendome.gradle.plugins.gitversion.model.jgit;




public class JGitRepositoryFactory implements GitRepositoryFactory {

    private final Logger logger = LoggerFactory.getLogger(JGitRepositoryFactory.class);


    @Override
    public CloseableGitRepository getRepository(File dir) {
        return IOUtils.unchecked(() -> doGetRepository(dir));
    }


    private CloseableGitRepository doGetRepository(File dir) throws IOException {

        logger.debug("Trying to open Git repository for directory {}", dir);