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

Code before:
 *
 * @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;
        case commitType.HIGHLIGHT:
          typeClass = 'commit-highlight';
          break;
        case commitType.MERGE:
          typeClass = 'commit-merge';

Review comment (suggestion):
It seems there is only one argument in `findClosesParent` function, so the second is extra
```suggestion
      const closestParent = findClosestParent(commit.parents);
```

Code after:
 *
 * @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.
    if (modifyGraph) {
      let typeClass;
      let commitSymbolType =
        commit.customType !== undefined && commit.customType !== ''
          ? commit.customType