Repository: mermaid-js/mermaid
File: packages/mermaid/src/diagrams/git/gitGraphRenderer.js (JavaScript)

Code before:

/**
 * Draws the commits with its symbol and labels. The function has two modes, one which only
 * calculates the positions and one that does the actual drawing. This for a simple way getting the
 * vertical layering correct in the graph.
 *
 * @param {any} svg
 * @param {any} commits
 * @param {any} modifyGraph
 */
const drawCommits = (svg, commits, modifyGraph) => {
  const gitGraphConfig = getConfig().gitGraph;
  const gBullets = svg.append('g').attr('class', 'commit-bullets');
  const gLabels = svg.append('g').attr('class', 'commit-labels');
  let pos = 0;

  if (dir === 'TB') {
    pos = 30;
  }

  const keys = Object.keys(commits);
  const sortedKeys = keys.sort((a, b) => {
    return commits[a].seq - commits[b].seq;
  });

  const isParallelCommits = getConfig().gitGraph.parallelCommits;
  sortedKeys.forEach((key) => {
    const commit = commits[key];

    if (isParallelCommits && commit.parents.length) {
      const closestParent = findClosestParent(commit.parents, commits);
      pos = dir === 'TB' ? commitPos[closestParent].y + 40 : commitPos[closestParent].x + 40;
    }

    const y = dir === 'TB' ? pos + 10 : branchPos[commit.branch].pos;
    const x = dir === 'TB' ? branchPos[commit.branch].pos : pos + 10;

    // Don't draw the commits now but calculate the positioning which is used by the branch lines etc.
    if (modifyGraph) {
      let typeClass;
      let commitSymbolType =
        commit.customType !== undefined && commit.customType !== ''
          ? commit.customType
          : commit.type;
      switch (commitSymbolType) {
        case commitType.NORMAL:
          typeClass = 'commit-normal';
          break;
        case commitType.REVERSE:
          typeClass = 'commit-reverse';
          break;

Review comment (suggestion):
There is already `gitGraphConfig` defined
```suggestion
  const isParallelCommits = gitGraphConfig.parallelCommits;
```

Code after:

/**
 * Draws the commits with its symbol and labels. The function has two modes, one which only
 * calculates the positions and one that does the actual drawing. This for a simple way getting the
 * vertical layering correct in the graph.
 *
 * @param {any} svg
 * @param {any} commits
 * @param {any} modifyGraph
 */
const drawCommits = (svg, commits, modifyGraph) => {
  const gitGraphConfig = getConfig().gitGraph;
  const gBullets = svg.append('g').attr('class', 'commit-bullets');
  const gLabels = svg.append('g').attr('class', 'commit-labels');
  let pos = 0;

  if (dir === 'TB') {
    pos = 30;
  }

  const keys = Object.keys(commits);
  const sortedKeys = keys.sort((a, b) => {
    return commits[a].seq - commits[b].seq;
  });

  const isParallelCommits = gitGraphConfig.parallelCommits;
  const layoutOffset = 10;
  const commitStep = 40;
  sortedKeys.forEach((key) => {
    const commit = commits[key];

    if (isParallelCommits) {
      if (commit.parents.length) {
        const closestParent = findClosestParent(commit.parents);
        pos =
          dir === 'TB'
            ? commitPos[closestParent].y + commitStep
            : commitPos[closestParent].x + commitStep;
      } else {
        pos = 0;
        if (dir === 'TB') {
          pos = 30;
        }
      }
    }

    const posWithOffset = pos + layoutOffset;
    const y = dir === 'TB' ? posWithOffset : branchPos[commit.branch].pos;
    const x = dir === 'TB' ? branchPos[commit.branch].pos : posWithOffset;

    // Don't draw the commits now but calculate the positioning which is used by the branch lines etc.