Class GitRepository

java.lang.Object
atessera.sensei.git.GitRepository
All Implemented Interfaces:
Closeable, AutoCloseable

public final class GitRepository extends Object implements Closeable
A local clone of a student git repository.

Instances are meant to be used inside a try-with-resources block so the cloned directory is recursively removed when the check finishes.

  • Constructor Details

    • GitRepository

      public GitRepository(String url, String branch, Path workDir) throws IOException
      Clones a repository into a fresh temporary directory.
      Parameters:
      url - repository URL
      branch - optional branch name; null or blank means the default branch
      workDir - parent directory for the clone
      Throws:
      IOException - when the clone cannot be created
  • Method Details

    • path

      public Path path()
      Returns the root directory of the clone.
      Returns:
      clone root directory
    • close

      public void close()
      Recursively removes the clone directory.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable