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.
    • 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

    • Repository

      public Repository(RepositoryLocationType repoLocation, Path localPath, URI remote, String repositoryName, PatchDiffParseOptions parseOptions, DiffFilter diffFilter)
      Creates a repository.
      Parameters:
      repoLocation - RepositoryLocationType From which location the repository is read from
      localPath - The local path where the repository can be found or should be cloned to.
      remote - The remote url of the repository. May be null if local.
      repositoryName - Name of the cloned repository (null if local)
      parseOptions - Omit some debug data to save RAM.
      diffFilter - Filter determining which files and commits to consider for diffs.
    • Repository

      public Repository(RepositoryLocationType repoLocation, Path localPath, URI remote, String repositoryName)
      Creates repository of the given source and with all other settings set to default values.
      See Also:
  • 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.variantsync.functjonal.Lazy<org.eclipse.jgit.api.Git> getGitRepo()
      Returns the internal jgit representation of this repository that allows to inspect the repositories history and content.
    • load

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