getGitState function

Future<GitRepoState?> getGitState({
  1. String? cwd,
})

Get the full git repository state.

Implementation

Future<GitRepoState?> getGitState({String? cwd}) async {
  try {
    final results = await Future.wait([
      getHead(cwd: cwd),
      getBranch(cwd: cwd),
      getRemoteUrl(cwd: cwd),
      getIsHeadOnRemote(cwd: cwd),
      getIsClean(cwd: cwd),
    ]);

    return GitRepoState(
      commitHash: results[0] as String,
      branchName: results[1] as String,
      remoteUrl: results[2] as String?,
      isHeadOnRemote: results[3] as bool,
      isClean: results[4] as bool,
      worktreeCount: 1, // Simplified
    );
  } catch (_) {
    return null;
  }
}