isGitRepository method

Future<bool> isGitRepository(
  1. String directoryToCheck
)

Checks if the directoryToCheck is a git directory and returns true if it is, otherwise false. In order to determine if it is a git repository, it will check whether the repository belongs to a git tree.

Implementation

Future<bool> isGitRepository(String directoryToCheck) async {
  ProcessResult processResult = await git_service.runGit(
      ['rev-parse', '--is-inside-work-tree'],
      throwOnError: false,
      echoOutput: false,
      processWorkingDir: directoryToCheck);

  return processResult.stdout.toString().toLowerCase().trim() == "true";
}