mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Address comments from PR
This commit is contained in:
24
lib/actions-util.js
generated
24
lib/actions-util.js
generated
@@ -75,7 +75,7 @@ const getCommitOid = async function (checkoutPath, ref = "HEAD") {
|
|||||||
// the merge commit, which must mean that git is available.
|
// the merge commit, which must mean that git is available.
|
||||||
// Even if this does go wrong, it's not a huge problem for the alerts to
|
// Even if this does go wrong, it's not a huge problem for the alerts to
|
||||||
// reported on the merge commit.
|
// reported on the merge commit.
|
||||||
let output = "";
|
let stderr = "";
|
||||||
try {
|
try {
|
||||||
let commitOid = "";
|
let commitOid = "";
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), ["rev-parse", ref], {
|
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), ["rev-parse", ref], {
|
||||||
@@ -85,7 +85,7 @@ const getCommitOid = async function (checkoutPath, ref = "HEAD") {
|
|||||||
commitOid += data.toString();
|
commitOid += data.toString();
|
||||||
},
|
},
|
||||||
stderr: (data) => {
|
stderr: (data) => {
|
||||||
output += data.toString();
|
stderr += data.toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cwd: checkoutPath,
|
cwd: checkoutPath,
|
||||||
@@ -93,11 +93,13 @@ const getCommitOid = async function (checkoutPath, ref = "HEAD") {
|
|||||||
return commitOid.trim();
|
return commitOid.trim();
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (output.includes("not a git repository")) {
|
if (stderr.includes("not a git repository")) {
|
||||||
core.info("Could not determine current commit SHA using git. Continuing with data from user input or environment. The checkout path provided to the action does not appear to be a git repository.");
|
core.info("Could not determine current commit SHA using git. Continuing with data from user input or environment. " +
|
||||||
|
"The checkout path provided to the action does not appear to be a git repository.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`Could not determine current commit SHA using git. Continuing with data from user input or environment. Failed to call git to determine merge base. Continuing with data from environment: ${output}`);
|
core.info(`Could not determine current commit SHA using git. Continuing with data from user input or environment. ` +
|
||||||
|
`Failed to call git to determine merge base. Continuing with data from environment: ${stderr}`);
|
||||||
}
|
}
|
||||||
return (0, exports.getOptionalInput)("sha") || (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
return (0, exports.getOptionalInput)("sha") || (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
||||||
}
|
}
|
||||||
@@ -113,7 +115,7 @@ const determineMergeBaseCommitOid = async function (checkoutPathOverride) {
|
|||||||
}
|
}
|
||||||
const mergeSha = (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
const mergeSha = (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
||||||
const checkoutPath = checkoutPathOverride ?? (0, exports.getOptionalInput)("checkout_path");
|
const checkoutPath = checkoutPathOverride ?? (0, exports.getOptionalInput)("checkout_path");
|
||||||
let output = "";
|
let stderr = "";
|
||||||
try {
|
try {
|
||||||
let commitOid = "";
|
let commitOid = "";
|
||||||
let baseOid = "";
|
let baseOid = "";
|
||||||
@@ -135,7 +137,7 @@ const determineMergeBaseCommitOid = async function (checkoutPathOverride) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
stderr: (data) => {
|
stderr: (data) => {
|
||||||
output += data.toString();
|
stderr += data.toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cwd: checkoutPath,
|
cwd: checkoutPath,
|
||||||
@@ -149,11 +151,13 @@ const determineMergeBaseCommitOid = async function (checkoutPathOverride) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (output.includes("not a git repository")) {
|
if (stderr.includes("not a git repository")) {
|
||||||
core.info("The checkout path provided to the action does not appear to be a git repository. Continuing with data from environment.");
|
core.info("The checkout path provided to the action does not appear to be a git repository. " +
|
||||||
|
"Will calculate the merge base on the server.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`Failed to call git to determine merge base. Continuing with data from environment: ${output}`);
|
core.info(`Failed to call git to determine merge base. Will calculate the merge base on ` +
|
||||||
|
`the server. Reason: ${stderr}`);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -2,7 +2,6 @@ import * as fs from "fs";
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import * as toolRunner from "@actions/exec/lib/toolrunner";
|
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export const getCommitOid = async function (
|
|||||||
// the merge commit, which must mean that git is available.
|
// the merge commit, which must mean that git is available.
|
||||||
// Even if this does go wrong, it's not a huge problem for the alerts to
|
// Even if this does go wrong, it's not a huge problem for the alerts to
|
||||||
// reported on the merge commit.
|
// reported on the merge commit.
|
||||||
let output = "";
|
let stderr = "";
|
||||||
try {
|
try {
|
||||||
let commitOid = "";
|
let commitOid = "";
|
||||||
await new toolrunner.ToolRunner(
|
await new toolrunner.ToolRunner(
|
||||||
@@ -76,7 +76,7 @@ export const getCommitOid = async function (
|
|||||||
commitOid += data.toString();
|
commitOid += data.toString();
|
||||||
},
|
},
|
||||||
stderr: (data) => {
|
stderr: (data) => {
|
||||||
output += data.toString();
|
stderr += data.toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cwd: checkoutPath,
|
cwd: checkoutPath,
|
||||||
@@ -84,13 +84,15 @@ export const getCommitOid = async function (
|
|||||||
).exec();
|
).exec();
|
||||||
return commitOid.trim();
|
return commitOid.trim();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (output.includes("not a git repository")) {
|
if (stderr.includes("not a git repository")) {
|
||||||
core.info(
|
core.info(
|
||||||
"Could not determine current commit SHA using git. Continuing with data from user input or environment. The checkout path provided to the action does not appear to be a git repository.",
|
"Could not determine current commit SHA using git. Continuing with data from user input or environment. " +
|
||||||
|
"The checkout path provided to the action does not appear to be a git repository.",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
core.info(
|
||||||
`Could not determine current commit SHA using git. Continuing with data from user input or environment. Failed to call git to determine merge base. Continuing with data from environment: ${output}`,
|
`Could not determine current commit SHA using git. Continuing with data from user input or environment. ` +
|
||||||
|
`Failed to call git to determine merge base. Continuing with data from environment: ${stderr}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +114,7 @@ export const determineMergeBaseCommitOid = async function (
|
|||||||
const mergeSha = getRequiredEnvParam("GITHUB_SHA");
|
const mergeSha = getRequiredEnvParam("GITHUB_SHA");
|
||||||
const checkoutPath =
|
const checkoutPath =
|
||||||
checkoutPathOverride ?? getOptionalInput("checkout_path");
|
checkoutPathOverride ?? getOptionalInput("checkout_path");
|
||||||
let output = "";
|
let stderr = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let commitOid = "";
|
let commitOid = "";
|
||||||
@@ -137,7 +139,7 @@ export const determineMergeBaseCommitOid = async function (
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
stderr: (data) => {
|
stderr: (data) => {
|
||||||
output += data.toString();
|
stderr += data.toString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cwd: checkoutPath,
|
cwd: checkoutPath,
|
||||||
@@ -154,13 +156,15 @@ export const determineMergeBaseCommitOid = async function (
|
|||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (output.includes("not a git repository")) {
|
if (stderr.includes("not a git repository")) {
|
||||||
core.info(
|
core.info(
|
||||||
"The checkout path provided to the action does not appear to be a git repository. Continuing with data from environment.",
|
"The checkout path provided to the action does not appear to be a git repository. " +
|
||||||
|
"Will calculate the merge base on the server.",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
core.info(
|
||||||
`Failed to call git to determine merge base. Continuing with data from environment: ${output}`,
|
`Failed to call git to determine merge base. Will calculate the merge base on ` +
|
||||||
|
`the server. Reason: ${stderr}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user