Skip to content

Commit ef25160

Browse files
Update packages/mermaid/src/diagrams/git/gitGraphAst.ts
Co-authored-by: Sidharth Vinod <[email protected]>
1 parent 6c1e5aa commit ef25160

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/mermaid/src/diagrams/git/gitGraphAst.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ export const commit = function (msg: string, id: string, type: number, tags?: st
105105

106106
export const branch = function (name: string, order?: number) {
107107
name = common.sanitizeText(name, getConfig());
108-
if (!state.records.branches.has(name)) {
108+
if (state.records.branches.has(name)) {
109+
throw new Error(
110+
`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")`
111+
);
112+
}
113+
109114
state.records.branches.set(name, state.records.head != null ? state.records.head.id : null);
110115
state.records.branchConfig.set(name, { name, order });
111116
checkout(name);
112117
log.debug('in createBranch');
113-
} else {
114-
throw new Error(
115-
`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")`
116-
);
117-
}
118118
};
119119

120120
export const merge = (

0 commit comments

Comments
 (0)