mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-09 02:27:05 +02:00
fixed checkout branch with no commits
This commit is contained in:
@@ -399,14 +399,11 @@ export const checkout = function (branch: string) {
|
||||
} else {
|
||||
curBranch = branch;
|
||||
const id = branches.get(curBranch);
|
||||
|
||||
if (id === null || id === undefined) {
|
||||
throw new Error('Branch ' + branch + ' has no commits');
|
||||
if (id === undefined || !id) {
|
||||
head = null;
|
||||
} else {
|
||||
head = commits.get(id) ?? null;
|
||||
}
|
||||
if (commits.get(id) === undefined) {
|
||||
throw new Error('Branch ' + branch + ' has no commits');
|
||||
}
|
||||
head = commits.get(id) ?? null;
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user