Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add support for commit input (fixes #1634) #1858

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
must use || and not ?? when falling back to commit when ref is no…
…t provided.

Signed-off-by: James Bradlee <james.bradlee@telenor.no>
  • Loading branch information
testersen committed Aug 20, 2024
commit 0865c4bfce7deea86ea9a5aebef018b997ab2a29
6 changes: 2 additions & 4 deletions __test__/input-helper.test.ts
Original file line number Diff line number Diff line change
@@ -163,10 +163,8 @@ describe('input-helper tests', () => {
inputs.commit = '0123456789012345678901234567890123456789'
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings).toBeTruthy()
expect(settings.ref).toBeTruthy()
expect(settings.ref).toStrictEqual(
'0123456789012345678901234567890123456789'
)
expect(settings.ref).toBeFalsy()
expect(settings.ref).toStrictEqual('')
expect(settings.commit).toBeTruthy()
expect(settings.commit).toStrictEqual(
'0123456789012345678901234567890123456789'
3 changes: 1 addition & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1717,7 +1717,6 @@ const path = __importStar(__nccwpck_require__(1017));
const workflowContextHelper = __importStar(__nccwpck_require__(9568));
function getInputs() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const result = {};
// 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}$/)) {
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 (isWorkflowRepository) {
result.ref = github.context.ref;
2 changes: 1 addition & 1 deletion src/input-helper.ts
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
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 (isWorkflowRepository) {
result.ref = github.context.ref