mirror of
https://github.com/tiktok/sparo.git
synced 2024-11-14 19:35:12 -05:00
Merge pull request #68 from tiktok/feat-checkout-detched
Feat checkout detched
This commit is contained in:
commit
16476655e4
2 changed files with 18 additions and 1 deletions
|
@ -111,7 +111,14 @@ export class CheckoutCommand implements ICommand<ICheckoutCommandOptions> {
|
|||
}
|
||||
|
||||
if (!operationBranch) {
|
||||
throw new Error(`Failed to get branch ${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
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "sparo",
|
||||
"comment": "Fix checkout command in a detached HEAD state",
|
||||
"type": "none"
|
||||
}
|
||||
],
|
||||
"packageName": "sparo"
|
||||
}
|
Loading…
Reference in a new issue