Class Repository

java.lang.Object
org.variantsync.diffdetective.datasets.Repository

public class Repository extends Object
Representation of git repositories used as datasets for DiffDetective.
Author:
Kevin Jedelhauser, Paul Maximilian Bittner
  • Field Details

    • DIFFDETECTIVE_DEFAULT_REPOSITORIES_DIRECTORY

      public static final Path DIFFDETECTIVE_DEFAULT_REPOSITORIES_DIRECTORY
    • repoLocation

      private final RepositoryLocationType repoLocation
      The location from where the input repository is read from.
    • localPath

      private final Path localPath
      The local path where the repository can be found or should be cloned to.
    • remote

      private final URI remote
      The remote url of the repository. May be null if local.
    • repositoryName

      private final String repositoryName
      The name of the repository. Used for debugging.
    • commitLister

      private CommitLister commitLister
      A function that extracts the list of commits that are represented by this repository instance.
    • diffFilter

      private DiffFilter diffFilter
      Filter determining which files and commits to consider for diffs.
    • parseOptions

      private PatchDiffParseOptions parseOptions
      Options to configure parsing and memory consumption (e.g., by not keeping full diffs in memory).
    • git

      private final org.variantsync.functjonal.Lazy<org.eclipse.jgit.api.Git> git
  • Constructor Details

  • Method Details

    • fromDirectory

      public static Repository fromDirectory(Path dirPath, String repoName)
      Creates a repository from an existing directory.
      Parameters:
      dirPath - The path to the repo directory relative to <WORKING_DIRECTORY>/repositories
      repoName - A name for the repository (currently not used)
      Returns:
      A repository from an existing directory
    • fromZip

      public static Repository fromZip(Path filePath, String repoName)
      Creates a repository from a local zip file.
      Parameters:
      filePath - The path to the zip file (absolute or relative to <WORKING_DIRECTORY>).
      repoName - A name for the repository (currently not used)
      Returns:
      A repository from a local zip file
    • fromRemote

      public static Repository fromRemote(Path localPath, URI repoUri, String repoName)
      Creates a repository from a remote repository.
      Parameters:
      localPath - Path to clone the repository to.
      repoUri - The address of the remote repository
      repoName - Name of the folder, where the git repository is cloned to
      Returns:
      A repository from a remote location (e.g. Github repository)
    • tryFromRemote

      public static Optional<Repository> tryFromRemote(Path localDir, String repoUri, String repoName)
      Creates a repository from a remote repository.
      Parameters:
      localDir - Directory to clone the repository to.
      repoUri - The address of the remote repository
      repoName - Name of the folder, where the git repository is cloned to
      Returns:
      A repository from a remote location (e.g. Github repository)
    • getRepoLocation

      public RepositoryLocationType getRepoLocation()
      Returns:
      the location type indicating how this repository is stored.
    • getLocalPath

      public Path getLocalPath()
      The path to the repository on disk. The path points to the root directory of the repository if the repository is stored in a directory. The path points to a zip file if the repository is stored in a zip file. The path points to a (possibly not existing) directory to which the repository should be cloned to if the repository is stored on a remote server.
      Returns:
      The path to the repository on disk.
      See Also:
    • getRemoteURI

      public URI getRemoteURI()
      URI of the origin of this repository (i.e., usually the location on a server where this repository was cloned from).
    • getRepositoryName

      public String getRepositoryName()
      The name of this repository. Should be unique.
    • setParseOptions

      public Repository setParseOptions(PatchDiffParseOptions parseOptions)
      Set options for parsing parts of this repository's evolution history.
      Parameters:
      parseOptions - Options for parsing the evolution history.
      Returns:
      this
    • setDiffFilter

      public Repository setDiffFilter(DiffFilter filter)
      Set the diff filter for reading this repository. The diff filter decides which commits and files should be considered for analyses.
      Parameters:
      filter - Filter to apply when traversing this repository's commit history.
      Returns:
      this
    • getDiffFilter

      public DiffFilter getDiffFilter()
      The diff filter decides which commits and files should be considered for analyses.
    • getParseOptions

      public PatchDiffParseOptions getParseOptions()
      Options that should be used when parsing the evolution history.
    • getGitRepo

      public org.eclipse.jgit.api.Git getGitRepo()
      Returns the internal jgit representation of this repository that allows to inspect the repositories history and content.
    • preload

      public void preload()
      Prepares the Git repository (e.g., clones it if necessary).
    • getCommit

      public org.eclipse.jgit.revwalk.RevCommit getCommit(String commitHash) throws IOException
      Returns a single commit from the repository. Note that this commit may not be part of getCommits().
      Throws:
      IOException
    • getCommits

      public Iterator<org.eclipse.jgit.revwalk.RevCommit> getCommits()
      Returns all commits in the repository's history.
    • load

      private org.eclipse.jgit.api.Git load()
      Loads this repository and returns a jgit representation to access it.