Improvements to GitInterface.

Change-Id: I26d67353ef7b04117b80252f658bc1689b1f646f
diff --git a/pom.xml b/pom.xml
index 8488bf5..d5a0e73 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,9 +24,9 @@
       <version>3.3.2.201404171909-r</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.commons</groupId>
+      <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
-      <version>1.3.2</version>
+      <version>2.4</version>
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
diff --git a/src/main/java/com/google/gwt/benchmark/git/GitInterface.java b/src/main/java/com/google/gwt/benchmark/git/GitInterface.java
index 0ddba68..212b840 100644
--- a/src/main/java/com/google/gwt/benchmark/git/GitInterface.java
+++ b/src/main/java/com/google/gwt/benchmark/git/GitInterface.java
@@ -17,12 +17,17 @@
 import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
+import com.google.gwt.benchmark.Benchmark;
 
 import org.eclipse.jgit.api.CheckoutCommand;
 import org.eclipse.jgit.api.CheckoutResult;
+import org.eclipse.jgit.api.CloneCommand;
+import org.eclipse.jgit.api.FetchCommand;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.LogCommand;
 import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.api.errors.InvalidRemoteException;
+import org.eclipse.jgit.api.errors.TransportException;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.revwalk.RevTree;
@@ -87,6 +92,18 @@
   }
 
   /**
+   * Clones a git repository.
+   */
+  public static void cloneRepository(String mainRepo, File targetRepo) throws GitAPIException,
+      InvalidRemoteException, TransportException {
+    log.info("Cloning repo from "  + mainRepo + " to " + targetRepo.getAbsolutePath());
+
+    CloneCommand clone = Git.cloneRepository().setDirectory(targetRepo).setURI(mainRepo);
+    Git git = clone.call();
+    Benchmark.log.info("Cloned repo from "  + mainRepo + " to " + targetRepo.getAbsolutePath());
+  }
+
+  /**
    * Returns the RevisionInfo for HEAD.
    */
   public static RevisionInfo getCurrentCommit(String repo) throws GitException {
@@ -135,6 +152,25 @@
   }
 
   /**
+   * Updates a git repository.
+   */
+  public static void updateGitRepository(String mainrepo) throws IOException, GitAPIException,
+      InvalidRemoteException, TransportException {
+    Benchmark.log.info("Updating git repo at "  + mainrepo);
+    Git repo = Git.open(new File(mainrepo));
+    FetchCommand fetchCommand = repo.fetch();
+    fetchCommand.call();
+  }
+
+  /**
+   * Creates a RevisionInfo from a RevCommit.
+   */
+  private static RevisionInfo createFromCommit(RevCommit commit) {
+    return new RevisionInfo(commit.getName(), commit.getShortMessage(),
+        commit.getCommitterIdent().getName(), commit.getCommitterIdent().getWhen());
+  }
+
+  /**
    * Returns the revision information if the commit modified a file with one of the extensions in
    * suffixes in one the paths in prefixes.
    * <p>
@@ -177,14 +213,6 @@
     return null;
   }
 
-  /**
-   * Creates a RevisionInfo from a RevCommit.
-   */
-  private static RevisionInfo createFromCommit(RevCommit commit) {
-    return new RevisionInfo(commit.getName(), commit.getShortMessage(),
-        commit.getCommitterIdent().getName(), commit.getCommitterIdent().getWhen());
-  }
-
   private static TreeFilter or(List<TreeFilter> treeFilterList) {
     Preconditions.checkArgument(treeFilterList.size() > 0);
     if (treeFilterList.size() == 1) {