From ef25160b8ed36b465f825f50251fa4917d78353a Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:06:09 -0400 Subject: [PATCH] Update packages/mermaid/src/diagrams/git/gitGraphAst.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index f7a732b3f7..c12c646a40 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -105,16 +105,16 @@ export const commit = function (msg: string, id: string, type: number, tags?: st export const branch = function (name: string, order?: number) { name = common.sanitizeText(name, getConfig()); - if (!state.records.branches.has(name)) { + if (state.records.branches.has(name)) { + throw new Error( + `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")` + ); + } + state.records.branches.set(name, state.records.head != null ? state.records.head.id : null); state.records.branchConfig.set(name, { name, order }); checkout(name); log.debug('in createBranch'); - } else { - throw new Error( - `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")` - ); - } }; export const merge = (