checkoutRef static method
Checks out a specific git ref Throws GitException if the operation fails
Implementation
static Future<void> checkoutRef(String ref, String? root) async {
try {
final result = await Process.run('git', ['checkout', ref], workingDirectory: root);
if (result.exitCode != 0) {
throw GitException('Failed to checkout ref $ref: ${result.stderr}');
}
} on ProcessException catch (e) {
throw GitException('Git command not found: ${e.message}');
} catch (e) {
throw GitException('Unexpected error: $e');
}
}