diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 4b61c3563..44597e9d7 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -45,20 +45,23 @@ const getConfig = (): Required => { }); return config; }; -const config = getConfig(); -const mainBranchName = config.mainBranchName; -const mainBranchOrder = config.mainBranchOrder; -const state = new ImperativeState(() => ({ - commits: new Map(), - head: null, - branchConfig: new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]), - branches: new Map([[mainBranchName, null]]), - currBranch: mainBranchName, - direction: 'LR', - seq: 0, - options: {}, -})); +const state = new ImperativeState(() => { + const config = getConfig(); + const mainBranchName = config.mainBranchName; + const mainBranchOrder = config.mainBranchOrder; + return { + mainBranchName, + commits: new Map(), + head: null, + branchConfig: new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]), + branches: new Map([[mainBranchName, null]]), + currBranch: mainBranchName, + direction: 'LR', + seq: 0, + options: {}, + }; +}); function getID() { return random({ length: 7 }); @@ -121,7 +124,7 @@ export const commit = function (commitDB: CommitDB) { branch: state.records.currBranch, }; state.records.head = newCommit; - log.info('main branch', mainBranchName); + log.info('main branch', config.mainBranchName); state.records.commits.set(newCommit.id, newCommit); state.records.branches.set(state.records.currBranch, newCommit.id); log.debug('in pushCommit ' + newCommit.id);