isAtGitRoot function
Check if the cwd is at the git root.
Implementation
Future<bool> isAtGitRoot({String? cwd}) async {
final currentCwd = cwd ?? Directory.current.path;
final gitRoot = findGitRoot(currentCwd);
if (gitRoot == null) return false;
try {
final resolved = Directory(currentCwd).resolveSymbolicLinksSync();
final resolvedRoot = Directory(gitRoot).resolveSymbolicLinksSync();
return resolved == resolvedRoot;
} catch (_) {
return currentCwd == gitRoot;
}
}