getCurrentRef static method

Future<String> getCurrentRef(
  1. String? root
)

Gets the current HEAD ref

Implementation

static Future<String> getCurrentRef(String? root) async {
  try {
    final result = await Process.run('git', ['rev-parse', 'HEAD'], workingDirectory: root);
    if (result.exitCode != 0) {
      throw GitException('Failed to get current HEAD ${result.stderr.toString()}');
    }
    return result.stdout.toString().trim();
  } on ProcessException catch (e) {
    throw GitException('Git command not found: ${e.message}');
  } catch (e) {
    throw GitException('Unexpected error: $e');
  }
}