diff --git a/lib/entry-points.js b/lib/entry-points.js index 21cf78a4b9..7c2dfb7c62 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -148800,7 +148800,7 @@ var runGitCommand = async function(workingDirectory, args, customErrorMessage, o if (stderr.includes("not a git repository")) { reason = "The checkout path provided to the action does not appear to be a git repository."; } - core5.info(`git call failed. ${customErrorMessage} Error: ${reason}`); + core5.debug(`git call failed. ${customErrorMessage} Error: ${reason}`); throw error3; } }; @@ -148813,6 +148813,9 @@ var getCommitOid = async function(checkoutPath, ref = "HEAD") { ); return stdout.trim(); } catch { + core5.info( + "Could not retrieve commit SHA from git; falling back to environment." + ); return getOptionalInput("sha") || getRequiredEnvParam("GITHUB_SHA"); } }; diff --git a/src/git-utils.test.ts b/src/git-utils.test.ts index b77d40a7ec..6bbb8564e1 100644 --- a/src/git-utils.test.ts +++ b/src/git-utils.test.ts @@ -252,6 +252,7 @@ test.serial( "determineBaseBranchHeadCommitOid not git repository", async (t) => { const infoStub = sinon.stub(core, "info"); + const debugStub = sinon.stub(core, "debug"); process.env["GITHUB_EVENT_NAME"] = "pull_request"; process.env["GITHUB_SHA"] = "100912429fab4cb230e66ffb11e738ac5194e73a"; @@ -260,17 +261,19 @@ test.serial( await gitUtils.determineBaseBranchHeadCommitOid(tmpDir); }); - t.deepEqual(1, infoStub.callCount); - t.deepEqual( - infoStub.firstCall.args[0], - "git call failed. Will calculate the base branch SHA on the server. Error: " + - "The checkout path provided to the action does not appear to be a git repository.", + t.deepEqual(0, infoStub.callCount); + t.assert( + debugStub.calledWithMatch( + "git call failed. Will calculate the base branch SHA on the server. Error: " + + "The checkout path provided to the action does not appear to be a git repository.", + ), ); }, ); test.serial("determineBaseBranchHeadCommitOid other error", async (t) => { const infoStub = sinon.stub(core, "info"); + const debugStub = sinon.stub(core, "debug"); process.env["GITHUB_EVENT_NAME"] = "pull_request"; process.env["GITHUB_SHA"] = "100912429fab4cb230e66ffb11e738ac5194e73a"; @@ -278,14 +281,14 @@ test.serial("determineBaseBranchHeadCommitOid other error", async (t) => { path.join(__dirname, "../../i-dont-exist"), ); t.deepEqual(result, undefined); - t.deepEqual(1, infoStub.callCount); + t.deepEqual(0, infoStub.callCount); t.assert( - infoStub.firstCall.args[0].startsWith( + debugStub.calledWithMatch( "git call failed. Will calculate the base branch SHA on the server. Error: ", ), ); t.assert( - !infoStub.firstCall.args[0].endsWith( + !debugStub.firstCall.args[0].endsWith( "The checkout path provided to the action does not appear to be a git repository.", ), ); diff --git a/src/git-utils.ts b/src/git-utils.ts index 0f5bf52a47..a4285e3979 100644 --- a/src/git-utils.ts +++ b/src/git-utils.ts @@ -92,7 +92,7 @@ export const runGitCommand = async function ( reason = "The checkout path provided to the action does not appear to be a git repository."; } - core.info(`git call failed. ${customErrorMessage} Error: ${reason}`); + core.debug(`git call failed. ${customErrorMessage} Error: ${reason}`); throw error; } }; @@ -119,6 +119,9 @@ export const getCommitOid = async function ( ); return stdout.trim(); } catch { + core.info( + "Could not retrieve commit SHA from git; falling back to environment.", + ); return getOptionalInput("sha") || getRequiredEnvParam("GITHUB_SHA"); } };