Class GitRepositoryValidator
java.lang.Object
io.jenkins.plugins.forensics.git.util.GitRepositoryValidator
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGitRepositoryValidator(SCM scm, Run<?, ?> build, FilePath workTree, TaskListener listener, edu.hm.hafner.util.FilteredLog logger) Creates a newGitRepositoryValidator. -
Method Summary
Modifier and TypeMethodDescriptionorg.jenkinsci.plugins.gitclient.GitClientCreates aGitClientusing the field values.getHead()Returns the GIT_COMMIT environment variable, or 'HEAD' if not set.getId()Returns the key for the associated SCM.getScm()Returns the associated SCM.booleanReturns whether the specified working tree contains a valid Git repository with full history (no shallow clone).booleanReturns whether the specified working tree contains a valid Git repository.booleanReturns whether the Git repository is configured as a shallow clone.
-
Field Details
-
INFO_SHALLOW_CLONE
Info message when a shallow clone is detected and blame/mining is skipped.- See Also:
-
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 newGitRepositoryValidator.- Parameters:
scm- theSCMto create the blamer forbuild- the current buildworkTree- the working tree to inspectlistener- a task listenerlogger- 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:
trueif the working tree contains a valid repository (including shallow clones),falseotherwise
-
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:
trueif the working tree contains a valid non-shallow repository,falseotherwise
-
isShallowClone
public boolean isShallowClone()Returns whether the Git repository is configured as a shallow clone.- Returns:
trueif the repository is a shallow clone,falseotherwise
-
createClient
public org.jenkinsci.plugins.gitclient.GitClient createClient()Creates aGitClientusing the field values.- Returns:
- a
GitClient
-
getHead
Returns the GIT_COMMIT environment variable, or 'HEAD' if not set.- Returns:
- a
GitClient
-
getId
Returns the key for the associated SCM.- Returns:
- the SCM key
-
getScm
Returns the associated SCM.- Returns:
- the SCM
-