mirror of
https://github.com/tiktok/sparo.git
synced 2024-11-27 09:36:04 -05:00
fix: checkoout in a detached state
This commit is contained in:
parent
6790cd2c67
commit
f5f80313d4
1 changed files with 8 additions and 1 deletions
|
@ -111,7 +111,14 @@ export class CheckoutCommand implements ICommand<ICheckoutCommandOptions> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!operationBranch) {
|
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}`);
|
throw new Error(`Failed to get branch ${operationBranch}`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (operationBranch !== currentBranch) {
|
if (operationBranch !== currentBranch) {
|
||||||
// 1. First, Sparo needs to see the branch matches any branch name
|
// 1. First, Sparo needs to see the branch matches any branch name
|
||||||
|
|
Loading…
Reference in a new issue