isGitDir static method

bool isGitDir()

Checks if current dir is git repository.

The result value is cached after first invocation. However, when the users starts local server and then runs git init this will not update its result. We might change this in the future.

Implementation

static bool isGitDir() {
  try {
    return 'git rev-parse --is-inside-work-tree'.firstLine?.trim() == 'true';
  } catch (e) {
    return false;
  }
}