mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
added gitgraph in imperative state
This commit is contained in:
parent
8ef30a2642
commit
24ba5b73da
@ -45,20 +45,23 @@ const getConfig = (): Required<GitGraphDiagramConfig> => {
|
|||||||
});
|
});
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
const config = getConfig();
|
|
||||||
const mainBranchName = config.mainBranchName;
|
|
||||||
const mainBranchOrder = config.mainBranchOrder;
|
|
||||||
|
|
||||||
const state = new ImperativeState<GitGraphState>(() => ({
|
const state = new ImperativeState<GitGraphState>(() => {
|
||||||
commits: new Map(),
|
const config = getConfig();
|
||||||
head: null,
|
const mainBranchName = config.mainBranchName;
|
||||||
branchConfig: new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]),
|
const mainBranchOrder = config.mainBranchOrder;
|
||||||
branches: new Map([[mainBranchName, null]]),
|
return {
|
||||||
currBranch: mainBranchName,
|
mainBranchName,
|
||||||
direction: 'LR',
|
commits: new Map(),
|
||||||
seq: 0,
|
head: null,
|
||||||
options: {},
|
branchConfig: new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]),
|
||||||
}));
|
branches: new Map([[mainBranchName, null]]),
|
||||||
|
currBranch: mainBranchName,
|
||||||
|
direction: 'LR',
|
||||||
|
seq: 0,
|
||||||
|
options: {},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
function getID() {
|
function getID() {
|
||||||
return random({ length: 7 });
|
return random({ length: 7 });
|
||||||
@ -121,7 +124,7 @@ export const commit = function (commitDB: CommitDB) {
|
|||||||
branch: state.records.currBranch,
|
branch: state.records.currBranch,
|
||||||
};
|
};
|
||||||
state.records.head = newCommit;
|
state.records.head = newCommit;
|
||||||
log.info('main branch', mainBranchName);
|
log.info('main branch', config.mainBranchName);
|
||||||
state.records.commits.set(newCommit.id, newCommit);
|
state.records.commits.set(newCommit.id, newCommit);
|
||||||
state.records.branches.set(state.records.currBranch, newCommit.id);
|
state.records.branches.set(state.records.currBranch, newCommit.id);
|
||||||
log.debug('in pushCommit ' + newCommit.id);
|
log.debug('in pushCommit ' + newCommit.id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user