Skip to content

fix!: use local git command to resolve existing commits instead of GitHub API#214

Open
mauriziovitale wants to merge 1 commit intonrwl:mainfrom
mauriziovitale:fix/nx-set-sha-commit-history
Open

fix!: use local git command to resolve existing commits instead of GitHub API#214
mauriziovitale wants to merge 1 commit intonrwl:mainfrom
mauriziovitale:fix/nx-set-sha-commit-history

Conversation

@mauriziovitale
Copy link
Copy Markdown

@mauriziovitale mauriziovitale commented Mar 25, 2026

Fix: Replace the API call with git merge-base --is-ancestor, which is local, O(1), and has no depth limit.

Fixes #144

@mauriziovitale mauriziovitale changed the title Replace the API call with git merge-base --is-ancestor commitExists breaks on branches with 100+ commits due to unpaginated Mar 25, 2026
@meeroslav
Copy link
Copy Markdown
Contributor

Hi @mauriziovitale,

Thank you for the PR. The proposed change looks solid.
Please also include the following changes:

  • bump version in package.json to 6.0.0
  • update README.md to reference v6
  • build code and include compiled .js file

Thank you!

Comment thread nx-set-shas.ts
process.stdout.write(`WARNING: Working directory '${workingDirectory}' doesn't exist.\n`);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be worth failing fast on shallow clones here. This change you are making fully relies on local history being complete enough for git merge-base --is-ancestor to be meaningful, and with a shallow checkout the action can otherwise fall through into “no previous successful workflow” behavior instead of surfacing the real configuration problem.

Something along these lines would make the failure mode much clearer:

  const isShallow = spawnSync('git', ['rev-parse', '--is-shallow-repository'], {
    encoding: 'utf-8',
  });

  if (isShallow.stdout?.trim() === 'true') {
    core.setFailed(
      'Shallow clone detected. nx-set-shas requires fetch-depth: 0 to work correctly. ' +
        'We also recommend filter: tree:0 to reduce checkout size. ' +
        'See https://github.com/nrwl/nx-set-shas for the recommended checkout configuration.',
    );
    return;
  }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: This is in addition to @meeroslav review notes above, those are also needed

@JamesHenry JamesHenry changed the title commitExists breaks on branches with 100+ commits due to unpaginated fix!: use local git command to resolve existing commits instead of GitHub API Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commit not found if more than 100 commits on a branch

3 participants