mirror of
https://github.com/actions/checkout.git
synced 2024-11-15 11:54:30 +08:00
must use ||
and not ??
when falling back to commit when ref is not provided.
Signed-off-by: James Bradlee <james.bradlee@telenor.no>
This commit is contained in:
parent
1be0f9404c
commit
0865c4bfce
@ -163,10 +163,8 @@ describe('input-helper tests', () => {
|
|||||||
inputs.commit = '0123456789012345678901234567890123456789'
|
inputs.commit = '0123456789012345678901234567890123456789'
|
||||||
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
||||||
expect(settings).toBeTruthy()
|
expect(settings).toBeTruthy()
|
||||||
expect(settings.ref).toBeTruthy()
|
expect(settings.ref).toBeFalsy()
|
||||||
expect(settings.ref).toStrictEqual(
|
expect(settings.ref).toStrictEqual('')
|
||||||
'0123456789012345678901234567890123456789'
|
|
||||||
)
|
|
||||||
expect(settings.commit).toBeTruthy()
|
expect(settings.commit).toBeTruthy()
|
||||||
expect(settings.commit).toStrictEqual(
|
expect(settings.commit).toStrictEqual(
|
||||||
'0123456789012345678901234567890123456789'
|
'0123456789012345678901234567890123456789'
|
||||||
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -1717,7 +1717,6 @@ const path = __importStar(__nccwpck_require__(1017));
|
|||||||
const workflowContextHelper = __importStar(__nccwpck_require__(9568));
|
const workflowContextHelper = __importStar(__nccwpck_require__(9568));
|
||||||
function getInputs() {
|
function getInputs() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
var _a;
|
|
||||||
const result = {};
|
const result = {};
|
||||||
// GitHub workspace
|
// GitHub workspace
|
||||||
let githubWorkspacePath = process.env['GITHUB_WORKSPACE'];
|
let githubWorkspacePath = process.env['GITHUB_WORKSPACE'];
|
||||||
@ -1753,7 +1752,7 @@ function getInputs() {
|
|||||||
if (result.commit && !result.commit.match(/^[0-9a-fA-F]{40}$/)) {
|
if (result.commit && !result.commit.match(/^[0-9a-fA-F]{40}$/)) {
|
||||||
throw new Error(`The commit SHA '${result.commit}' is not a valid SHA.`);
|
throw new Error(`The commit SHA '${result.commit}' is not a valid SHA.`);
|
||||||
}
|
}
|
||||||
result.ref = (_a = core.getInput('ref')) !== null && _a !== void 0 ? _a : result.commit;
|
result.ref = core.getInput('ref') || result.commit;
|
||||||
if (!result.ref) {
|
if (!result.ref) {
|
||||||
if (isWorkflowRepository) {
|
if (isWorkflowRepository) {
|
||||||
result.ref = github.context.ref;
|
result.ref = github.context.ref;
|
||||||
|
@ -62,7 +62,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||||||
throw new Error(`The commit SHA '${result.commit}' is not a valid SHA.`)
|
throw new Error(`The commit SHA '${result.commit}' is not a valid SHA.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.ref = core.getInput('ref') ?? result.commit
|
result.ref = core.getInput('ref') || result.commit
|
||||||
if (!result.ref) {
|
if (!result.ref) {
|
||||||
if (isWorkflowRepository) {
|
if (isWorkflowRepository) {
|
||||||
result.ref = github.context.ref
|
result.ref = github.context.ref
|
||||||
|
Loading…
Reference in New Issue
Block a user