Class GitDirLocator

java.lang.Object
pl.project13.core.util.GitDirLocator

public class GitDirLocator extends Object
This class encapsulates logic to locate a valid .git directory of the currently used project. If it's not already specified, this logic will try to find it.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GitDirLocator(File projectBasedir, boolean useNativeGit, boolean shouldFailOnNoGitDirectory)
    Constructor to encapsulates all references required to locate a valid .git directory
  • Method Summary

    Modifier and Type
    Method
    Description
    lookupGitDirectory(File manuallyConfiguredDir)
    Attempts to lookup a valid .git directory of the currently used project.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GitDirLocator

      public GitDirLocator(File projectBasedir, boolean useNativeGit, boolean shouldFailOnNoGitDirectory)
      Constructor to encapsulates all references required to locate a valid .git directory
      Parameters:
      projectBasedir - The project basedir that will be used as last resort to search the parent project hierarchy until a .git directory is found.
      useNativeGit - Boolean that indicates if we use the native git implementation or the jGit Implementation. For the native git we usually need to use the parent "git"-Folder, as git can not run commands in "your-project/.git".
      shouldFailOnNoGitDirectory - Boolean that indicates if the process should fail if no git directory can be found.
  • Method Details

    • lookupGitDirectory

      @Nullable public File lookupGitDirectory(@Nonnull File manuallyConfiguredDir) throws GitCommitIdExecutionException
      Attempts to lookup a valid .git directory of the currently used project.
      Parameters:
      manuallyConfiguredDir - A user has the ability to configure a git-directory with the dotGitDirectory configuration setting. By default it should be simply ${project.basedir}/.git
      Returns:
      A valid .git directory, or null if none could be found under the user specified location or within the project or it's reactor projects.
      Throws:
      GitCommitIdExecutionException