// Path: src/main/java/com/bazoud/elasticsearch/river/git/beans/Context.java
// @Data
// @SuppressWarnings("PMD.UnusedPrivateField")
// public class Context {
//     private String name;
//     private String uri;
//     private File projectPath;
//     private Repository repository;
//     private String workingDir =
//         System.getProperty("user.home") + File.separator + ".elasticsearch-river-git";
//     private Collection<Ref> refs;
//     private Client client;
//     private Optional<Pattern> issuePattern = Optional.absent();
//     private String issueRegex;
//     private boolean indexingDiff;
//     private long updateRate = TimeUnit.MILLISECONDS.convert(15, TimeUnit.MINUTES);
//     private String type = "git";
//     private String riverName;
//     private String riverIndexName;
// }


import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import com.bazoud.elasticsearch.river.git.beans.Context;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;
package com.bazoud.elasticsearch.river.git.flow.predicates;



/**
 * @author Olivier Bazoud
 */
public class FetchOrCloneRepositoryPredicate implements Predicate<Context> {
    private static ESLogger logger = Loggers.getLogger(FetchOrCloneRepositoryPredicate.class);

    @Override
    public boolean apply(Context context) {
        try {
            final Repository repository = new FileRepositoryBuilder()
                .setGitDir(context.getProjectPath())
                .readEnvironment()
                .findGitDir()
                .setMustExist(false)
// Path: src/main/java/com/bazoud/elasticsearch/river/git/beans/Context.java
// @Data
// @SuppressWarnings("PMD.UnusedPrivateField")
// public class Context {
//     private String name;
//     private String uri;
//     private File projectPath;
//     private Repository repository;
//     private String workingDir =
//         System.getProperty("user.home") + File.separator + ".elasticsearch-river-git";
//     private Collection<Ref> refs;
//     private Client client;
//     private Optional<Pattern> issuePattern = Optional.absent();
//     private String issueRegex;
//     private boolean indexingDiff;
//     private long updateRate = TimeUnit.MILLISECONDS.convert(15, TimeUnit.MINUTES);
//     private String type = "git";
//     private String riverName;
//     private String riverIndexName;
// }


// Path: src/main/java/com/bazoud/elasticsearch/river/git/flow/predicates/FetchOrCloneRepositoryPredicate.java
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import com.bazoud.elasticsearch.river.git.beans.Context;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;

package com.bazoud.elasticsearch.river.git.flow.predicates;



/**
 * @author Olivier Bazoud
 */
public class FetchOrCloneRepositoryPredicate implements Predicate<Context> {
    private static ESLogger logger = Loggers.getLogger(FetchOrCloneRepositoryPredicate.class);

    @Override
    public boolean apply(Context context) {
        try {
            final Repository repository = new FileRepositoryBuilder()
                .setGitDir(context.getProjectPath())
                .readEnvironment()
                .findGitDir()
                .setMustExist(false)
                .build();