diff --git a/scan/dist/index.js b/scan/dist/index.js index da42bcf7..40372a72 100644 --- a/scan/dist/index.js +++ b/scan/dist/index.js @@ -135150,21 +135150,42 @@ var require_utils10 = __commonJS({ } __name(getInputs, "getInputs"); function getPrSha() { - if (process.env.QODANA_PR_SHA) { - return process.env.QODANA_PR_SHA; + return __awaiter3(this, void 0, void 0, function* () { + if (process.env.QODANA_PR_SHA) { + return process.env.QODANA_PR_SHA; + } + if (github2.context.payload.pull_request !== void 0) { + const output = yield gitOutput([ + "merge-base", + github2.context.payload.pull_request.base.sha, + github2.context.payload.pull_request.head.sha + ]); + if (output.exitCode === 0) { + return output.stdout.trim(); + } else { + return github2.context.payload.pull_request.base.sha; + } + } + return ""; + }); + } + __name(getPrSha, "getPrSha"); + function getHeadSha() { + if (process.env.QODANA_REVISION) { + return process.env.QODANA_REVISION; } if (github2.context.payload.pull_request !== void 0) { - return github2.context.payload.pull_request.base.sha; + return github2.context.payload.pull_request.head.sha; } - return ""; + return github2.context.sha; } - __name(getPrSha, "getPrSha"); + __name(getHeadSha, "getHeadSha"); function qodana(inputs_1) { return __awaiter3(this, arguments, void 0, function* (inputs, args = []) { if (args.length === 0) { args = (0, qodana_12.getQodanaScanArgs)(inputs.args, inputs.resultsDir, inputs.cacheDir); if (inputs.prMode) { - const sha = getPrSha(); + const sha = yield getPrSha(); if (sha !== "") { args.push("--commit", sha); } @@ -135172,7 +135193,7 @@ var require_utils10 = __commonJS({ } return (yield exec.getExecOutput(qodana_12.EXECUTABLE, args, { ignoreReturnCode: true, - env: Object.assign(Object.assign({}, process.env), { NONINTERACTIVE: "1" }) + env: Object.assign(Object.assign({}, process.env), { QODANA_REVISION: getHeadSha(), NONINTERACTIVE: "1" }) })).exitCode; }); } @@ -135469,6 +135490,12 @@ ${comment_tag_pattern}`; }); } __name(git, "git"); + function gitOutput(args_1) { + return __awaiter3(this, arguments, void 0, function* (args, options = {}) { + return yield exec.getExecOutput("git", args, options); + }); + } + __name(gitOutput, "gitOutput"); function createPr(title, repo, base, head) { return __awaiter3(this, void 0, void 0, function* () { const prBodyFile = path_1.default.join(os.tmpdir(), "pr-body.txt");