Class GitRepositoryValidator

java.lang.Object
io.jenkins.plugins.forensics.git.util.GitRepositoryValidator

public class GitRepositoryValidator extends Object
Inspects a given working tree and determines if this path is a valid Git repository that can be used to run one of the forensics analyzers.
Author:
Ullrich Hafner
  • Field Details

    • INFO_SHALLOW_CLONE

      public static final String INFO_SHALLOW_CLONE
      Info message when a shallow clone is detected and blame/mining is skipped.
      See Also:
    • INFO_SHALLOW_CLONE_COMMIT_RECORDING

      public static final String INFO_SHALLOW_CLONE_COMMIT_RECORDING
      Info message when a shallow clone is detected but commit recording is still performed.
      See Also:
  • Constructor Details

    • GitRepositoryValidator

      public GitRepositoryValidator(SCM scm, Run<?,?> build, FilePath workTree, TaskListener listener, edu.hm.hafner.util.FilteredLog logger)
      Creates a new GitRepositoryValidator.
      Parameters:
      scm - the SCM to create the blamer for
      build - the current build
      workTree - the working tree to inspect
      listener - a task listener
      logger - a logger to report error messages
  • Method Details

    • isGitRepository

      public boolean isGitRepository()
      Returns whether the specified working tree contains a valid Git repository. Shallow clones are accepted for operations that do not require full history (e.g., commit recording).
      Returns:
      true if the working tree contains a valid repository (including shallow clones), false otherwise
    • isFullGitRepository

      public boolean isFullGitRepository()
      Returns whether the specified working tree contains a valid Git repository with full history (no shallow clone). This is required for operations that need full commit history, such as blame analysis and repository mining.
      Returns:
      true if the working tree contains a valid non-shallow repository, false otherwise
    • isShallowClone

      public boolean isShallowClone()
      Returns whether the Git repository is configured as a shallow clone.
      Returns:
      true if the repository is a shallow clone, false otherwise
    • createClient

      public org.jenkinsci.plugins.gitclient.GitClient createClient()
      Creates a GitClient using the field values.
      Returns:
      a GitClient
    • getHead

      public String getHead()
      Returns the GIT_COMMIT environment variable, or 'HEAD' if not set.
      Returns:
      a GitClient
    • getId

      public String getId()
      Returns the key for the associated SCM.
      Returns:
      the SCM key
    • getScm

      public SCM getScm()
      Returns the associated SCM.
      Returns:
      the SCM