diff --git a/__test__/input-helper.test.ts b/__test__/input-helper.test.ts index 9514cb4..e0f711b 100644 --- a/__test__/input-helper.test.ts +++ b/__test__/input-helper.test.ts @@ -133,6 +133,15 @@ describe('input-helper tests', () => { expect(settings.commit).toBe('1111111111222222222233333333334444444444') }) + it('sets ref to empty when explicit sha-256', async () => { + inputs.ref = '1111111111222222222233333333334444444444555555555566666666667777' + const settings: IGitSourceSettings = await inputHelper.getInputs() + expect(settings.ref).toBeFalsy() + expect(settings.commit).toBe( + '1111111111222222222233333333334444444444555555555566666666667777' + ) + }) + it('sets sha to empty when explicit ref', async () => { inputs.ref = 'refs/heads/some-other-ref' const settings: IGitSourceSettings = await inputHelper.getInputs() diff --git a/__test__/ref-helper.test.ts b/__test__/ref-helper.test.ts index 4943abd..e4837f5 100644 --- a/__test__/ref-helper.test.ts +++ b/__test__/ref-helper.test.ts @@ -3,6 +3,8 @@ import * as refHelper from '../lib/ref-helper' import {IGitCommandManager} from '../lib/git-command-manager' const commit = '1234567890123456789012345678901234567890' +const sha256Commit = + '1234567890123456789012345678901234567890123456789012345678901234' let git: IGitCommandManager describe('ref-helper tests', () => { @@ -37,6 +39,12 @@ describe('ref-helper tests', () => { expect(checkoutInfo.startPoint).toBeFalsy() }) + it('getCheckoutInfo sha-256 only', async () => { + const checkoutInfo = await refHelper.getCheckoutInfo(git, '', sha256Commit) + expect(checkoutInfo.ref).toBe(sha256Commit) + expect(checkoutInfo.startPoint).toBeFalsy() + }) + it('getCheckoutInfo refs/heads/', async () => { const checkoutInfo = await refHelper.getCheckoutInfo( git, diff --git a/dist/index.js b/dist/index.js index fe3f317..57729b2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2021,7 +2021,7 @@ function getInputs() { } } // 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})$/)) { result.commit = result.ref; result.ref = ''; } @@ -2444,7 +2444,7 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref return; } // Extract details from message - const match = commitInfo.match(/Merge ([0-9a-f]{40}) into ([0-9a-f]{40})/); + const match = commitInfo.match(/Merge ([0-9a-f]{40}|[0-9a-f]{64}) into ([0-9a-f]{40}|[0-9a-f]{64})/); if (!match) { core.debug('Unexpected message format'); return; diff --git a/src/input-helper.ts b/src/input-helper.ts index 059232f..e0c61e2 100644 --- a/src/input-helper.ts +++ b/src/input-helper.ts @@ -71,7 +71,7 @@ export async function getInputs(): Promise { } } // 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})$/)) { result.commit = result.ref result.ref = '' } diff --git a/src/ref-helper.ts b/src/ref-helper.ts index 5130f53..05362bd 100644 --- a/src/ref-helper.ts +++ b/src/ref-helper.ts @@ -258,7 +258,7 @@ export async function checkCommitInfo( } // Extract details from message - const match = commitInfo.match(/Merge ([0-9a-f]{40}) into ([0-9a-f]{40})/) + const match = commitInfo.match(/Merge ([0-9a-f]{40}|[0-9a-f]{64}) into ([0-9a-f]{40}|[0-9a-f]{64})/) if (!match) { core.debug('Unexpected message format') return