feat: display commit hash in detached HEAD state (#832)

This commit is contained in:
Scott Densmore
2025-06-08 14:59:18 -07:00
committed by GitHub
parent 394312b9c2
commit 9104ac02f7
2 changed files with 38 additions and 5 deletions

View File

@@ -27,7 +27,17 @@ export function useGitBranchName(cwd: string): string | undefined {
if (branch && branch !== 'HEAD') {
setBranchName(branch);
} else {
setBranchName(undefined);
exec(
'git rev-parse --short HEAD',
{ cwd },
(error, stdout, _stderr) => {
if (error) {
setBranchName(undefined);
return;
}
setBranchName(stdout.toString().trim());
},
);
}
},
),