Class GitFileLister

java.lang.Object
io.github.sergeloie.languagecheck.scan.GitFileLister

public final class GitFileLister extends Object
Lists the project files git knows about using git ls-files --cached --others --exclude-standard: tracked files, staged files, and untracked files that are not git-ignored.

The subprocess output is redirected to a temporary file and read back afterwards - on Windows the default pipe buffer truncates large outputs, so stdout is never streamed through a pipe.

  • Field Details

    • DEFAULT_TIMEOUT_SECONDS

      public static final long DEFAULT_TIMEOUT_SECONDS
      Default timeout for the git subprocess, in seconds.
      See Also:
  • Constructor Details

    • GitFileLister

      public GitFileLister(File projectDir)
    • GitFileLister

      public GitFileLister(File projectDir, long timeoutSeconds)
  • Method Details

    • isGitRepository

      public boolean isGitRepository()
      True if projectDir looks like the root of a git working tree (a .git entry exists - a directory for a normal clone, a file for worktrees and submodules).
    • listRelativeFiles

      public List<String> listRelativeFiles()
      List all git-known files, relative to the project root.
      Returns:
      relative paths with '/' separators
      Throws:
      IllegalStateException - when the project is not a git repository
      org.gradle.api.GradleException - when git fails or times out