fix: checkoout in a detached state

This commit is contained in:
Cheng Liu 2024-04-30 10:32:52 -07:00
parent 6790cd2c67
commit f5f80313d4
No known key found for this signature in database
GPG key ID: EEC8452F7DB85CD6

View file

@ -111,7 +111,14 @@ export class CheckoutCommand implements ICommand<ICheckoutCommandOptions> {
}
if (!operationBranch) {
if (!currentBranch) {
// If current branch is missing, it means the repository is in a detached HEAD state.
// Let's treat it as a commit SHA for convenience now.
checkoutTargetKind = 'commit';
} else {
// This should not happen
throw new Error(`Failed to get branch ${operationBranch}`);
}
} else {
if (operationBranch !== currentBranch) {
// 1. First, Sparo needs to see the branch matches any branch name