Skip to content

fix: expand SHA regex to support SHA-256 (64-char) commit hashes#2413

Closed
yaananth wants to merge 1 commit into
actions:mainfrom
yaananth:sha256/fix-input-helper-regex
Closed

fix: expand SHA regex to support SHA-256 (64-char) commit hashes#2413
yaananth wants to merge 1 commit into
actions:mainfrom
yaananth:sha256/fix-input-helper-regex

Conversation

@yaananth
Copy link
Copy Markdown
Contributor

Summary

Update input-helper.ts to recognize both 40-char (SHA-1) and 64-char (SHA-256) hex strings as commit SHAs. Rebuild dist/index.js.

Changes

  • src/input-helper.ts: Update regex from /^[0-9a-fA-F]{40}$/ to /^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$/
  • dist/index.js: Rebuilt bundle

Validation

  • Build passes (npm run build)
  • 8 test suites, 96 tests pass (npm test)

Context

  • Parent epic: SHA-256 Support for Git Repositories

Automated by project-board-agents-plugin via /project-board-agents:lead
Board: https://github.com/orgs/github/projects/24272/views/1
Item: [P0] Fix SHA-1 regex in actions/checkout input-helper.ts
Run: sha256-p0-checkout-00050

Update input-helper.ts to recognize both 40-char (SHA-1) and 64-char
(SHA-256) hex strings as commit SHAs. Rebuild dist/index.js.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/input-helper.ts
}
// SHA?
else if (result.ref.match(/^[0-9a-fA-F]{40}$/)) {
else if (result.ref.match(/^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$/)) {
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.

the existing test at __test__/input-helper.test.ts line 129–134 only covers 40-char SHA inputs, can we add one for 64-char SHAs to correctly identity it as a commit and that it's not treated as a branch. e.g.:

it('sets ref to empty when explicit sha-256', async () => {
  inputs.ref = '1111111111222222222233333333334444444444555555555566666666667777'
  const settings = await inputHelper.getInputs()
  expect(settings.ref).toBeFalsy()
  expect(settings.commit).toBe('1111111111222222222233333333334444444444555555555566666666667777')
})
@salmanmkc
Copy link
Copy Markdown
Contributor

I think we can combine this PR with this PR: #2414, what do you think? I think the automation created two PRs, since I had made three issues before for checkout sha256 work, however it somehow managed to combine two into #2414 but didn't combine it with this PR.

@yaananth
Copy link
Copy Markdown
Contributor Author

Closing in favor of #2414, which now includes the input-helper change plus additional SHA-256 test coverage.

@yaananth yaananth closed this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants