hasWorktreeChanges method
Check whether a worktree has uncommitted changes or new commits since creation.
Implementation
Future<bool> hasWorktreeChanges(
String worktreePath,
String headCommit,
) async {
final statusResult = await _execGit([
'status',
'--porcelain',
], cwd: worktreePath);
if (statusResult.code != 0) return true;
if (statusResult.stdout.trim().isNotEmpty) return true;
final revListResult = await _execGit([
'rev-list',
'--count',
'$headCommit..HEAD',
], cwd: worktreePath);
if (revListResult.code != 0) return true;
if ((int.tryParse(revListResult.stdout.trim()) ?? 0) > 0) return true;
return false;
}