@@ -3359,7 +3359,7 @@ module.exports = {"name":"@octokit/rest","version":"16.43.1","publishConfig":{"a
33593359/***/ }),
33603360
33613361/***/ 227:
3362- /***/ (function(__unusedmodule, exports) {
3362+ /***/ (function(__unusedmodule, exports, __webpack_require__ ) {
33633363
33643364"use strict";
33653365
@@ -3372,7 +3372,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
33723372 step((generator = generator.apply(thisArg, _arguments || [])).next());
33733373 });
33743374};
3375+ var __importStar = (this && this.__importStar) || function (mod) {
3376+ if (mod && mod.__esModule) return mod;
3377+ var result = {};
3378+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
3379+ result["default"] = mod;
3380+ return result;
3381+ };
33753382Object.defineProperty(exports, "__esModule", { value: true });
3383+ const url_1 = __webpack_require__(835);
3384+ const core = __importStar(__webpack_require__(470));
3385+ const github = __importStar(__webpack_require__(469));
33763386function getCheckoutInfo(git, ref, commit) {
33773387 return __awaiter(this, void 0, void 0, function* () {
33783388 if (!git) {
@@ -3468,6 +3478,85 @@ function getRefSpec(ref, commit) {
34683478 }
34693479}
34703480exports.getRefSpec = getRefSpec;
3481+ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref, commit) {
3482+ return __awaiter(this, void 0, void 0, function* () {
3483+ try {
3484+ // GHES?
3485+ if (isGhes()) {
3486+ return;
3487+ }
3488+ // Auth token?
3489+ if (!token) {
3490+ return;
3491+ }
3492+ // Public PR synchronize, for workflow repo?
3493+ if (fromPayload('repository.private') !== false ||
3494+ github.context.eventName !== 'pull_request' ||
3495+ fromPayload('action') !== 'synchronize' ||
3496+ repositoryOwner !== github.context.repo.owner ||
3497+ repositoryName !== github.context.repo.repo ||
3498+ ref !== github.context.ref ||
3499+ !ref.startsWith('refs/pull/') ||
3500+ commit !== github.context.sha) {
3501+ return;
3502+ }
3503+ // Head SHA
3504+ const expectedHeadSha = fromPayload('after');
3505+ if (!expectedHeadSha) {
3506+ core.debug('Unable to determine head sha');
3507+ return;
3508+ }
3509+ // Base SHA
3510+ const expectedBaseSha = fromPayload('pull_request.base.sha');
3511+ if (!expectedBaseSha) {
3512+ core.debug('Unable to determine base sha');
3513+ return;
3514+ }
3515+ // Expected message?
3516+ const expectedMessage = `Merge ${expectedHeadSha} into ${expectedBaseSha}`;
3517+ if (commitInfo.indexOf(expectedMessage) >= 0) {
3518+ return;
3519+ }
3520+ // Extract details from message
3521+ const match = commitInfo.match(/Merge ([0-9a-f]{40}) into ([0-9a-f]{40})/);
3522+ if (!match) {
3523+ core.debug('Unexpected message format');
3524+ return;
3525+ }
3526+ // Post telemetry
3527+ const actualHeadSha = match[1];
3528+ if (actualHeadSha !== expectedHeadSha) {
3529+ core.debug(`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`);
3530+ const octokit = new github.GitHub(token, {
3531+ userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload('number')};run_id=${process.env['GITHUB_RUN_ID']};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})`
3532+ });
3533+ yield octokit.repos.get({ owner: repositoryOwner, repo: repositoryName });
3534+ }
3535+ }
3536+ catch (err) {
3537+ core.debug(`Error when validating commit info: ${err.stack}`);
3538+ }
3539+ });
3540+ }
3541+ exports.checkCommitInfo = checkCommitInfo;
3542+ function fromPayload(path) {
3543+ return select(github.context.payload, path);
3544+ }
3545+ function select(obj, path) {
3546+ if (!obj) {
3547+ return undefined;
3548+ }
3549+ const i = path.indexOf('.');
3550+ if (i < 0) {
3551+ return obj[path];
3552+ }
3553+ const key = path.substr(0, i);
3554+ return select(obj[key], path.substr(i + 1));
3555+ }
3556+ function isGhes() {
3557+ const ghUrl = new url_1.URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
3558+ return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
3559+ }
34713560
34723561
34733562/***/ }),
@@ -5718,7 +5807,8 @@ class GitCommandManager {
57185807 }
57195808 log1() {
57205809 return __awaiter(this, void 0, void 0, function* () {
5721- yield this.execGit(['log', '-1']);
5810+ const output = yield this.execGit(['log', '-1']);
5811+ return output.stdout;
57225812 });
57235813 }
57245814 remoteAdd(remoteName, remoteUrl) {
@@ -6057,7 +6147,9 @@ function getSource(settings) {
60576147 }
60586148 }
60596149 // Dump some info about the checked out commit
6060- yield git.log1();
6150+ const commitInfo = yield git.log1();
6151+ // Check for incorrect pull request merge commit
6152+ yield refHelper.checkCommitInfo(settings.authToken, commitInfo, settings.repositoryOwner, settings.repositoryName, settings.ref, settings.commit);
60616153 }
60626154 finally {
60636155 // Remove auth
0 commit comments