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) {
|
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
|
||||||
|
|
|
@ -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