mirror of
https://github.com/tj-actions/changed-files
synced 2025-03-05 21:06:25 +00:00
remove: unused code (#2014)
This commit is contained in:
parent
2ca8dc42f6
commit
90941b398f
5 changed files with 38 additions and 128 deletions
94
dist/index.js
generated
vendored
94
dist/index.js
generated
vendored
|
@ -1107,8 +1107,8 @@ const getSHAForNonPullRequestEvent = (_j) => __awaiter(void 0, [_j], void 0, fun
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
exports.getSHAForNonPullRequestEvent = getSHAForNonPullRequestEvent;
|
exports.getSHAForNonPullRequestEvent = getSHAForNonPullRequestEvent;
|
||||||
const getSHAForPullRequestEvent = (_o) => __awaiter(void 0, [_o], void 0, function* ({ inputs, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs, remoteName, isFork }) {
|
const getSHAForPullRequestEvent = (_o) => __awaiter(void 0, [_o], void 0, function* ({ inputs, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs, remoteName }) {
|
||||||
var _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
var _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
||||||
let targetBranch = (_q = (_p = github.context.payload.pull_request) === null || _p === void 0 ? void 0 : _p.base) === null || _q === void 0 ? void 0 : _q.ref;
|
let targetBranch = (_q = (_p = github.context.payload.pull_request) === null || _p === void 0 ? void 0 : _p.base) === null || _q === void 0 ? void 0 : _q.ref;
|
||||||
const currentBranch = (_s = (_r = github.context.payload.pull_request) === null || _r === void 0 ? void 0 : _r.head) === null || _s === void 0 ? void 0 : _s.ref;
|
const currentBranch = (_s = (_r = github.context.payload.pull_request) === null || _r === void 0 ? void 0 : _r.head) === null || _s === void 0 ? void 0 : _s.ref;
|
||||||
if (inputs.sinceLastRemoteCommit) {
|
if (inputs.sinceLastRemoteCommit) {
|
||||||
|
@ -1247,18 +1247,13 @@ const getSHAForPullRequestEvent = (_o) => __awaiter(void 0, [_o], void 0, functi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (github.context.payload.action === 'closed' || isFork) {
|
previousSha = (_x = (_w = github.context.payload.pull_request) === null || _w === void 0 ? void 0 : _w.base) === null || _x === void 0 ? void 0 : _x.sha;
|
||||||
previousSha = (_x = (_w = github.context.payload.pull_request) === null || _w === void 0 ? void 0 : _w.base) === null || _x === void 0 ? void 0 : _x.sha;
|
if (!previousSha) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
previousSha = yield (0, utils_1.getRemoteBranchHeadSha)({
|
previousSha = yield (0, utils_1.getRemoteBranchHeadSha)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
branch: targetBranch,
|
remoteName,
|
||||||
remoteName
|
branch: targetBranch
|
||||||
});
|
});
|
||||||
if (!previousSha) {
|
|
||||||
previousSha = (_z = (_y = github.context.payload.pull_request) === null || _y === void 0 ? void 0 : _y.base) === null || _z === void 0 ? void 0 : _z.sha;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isShallow) {
|
if (isShallow) {
|
||||||
if (!(yield (0, utils_1.canDiffCommits)({
|
if (!(yield (0, utils_1.canDiffCommits)({
|
||||||
|
@ -1295,7 +1290,7 @@ const getSHAForPullRequestEvent = (_o) => __awaiter(void 0, [_o], void 0, functi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!previousSha || previousSha === currentSha) {
|
if (!previousSha || previousSha === currentSha) {
|
||||||
previousSha = (_1 = (_0 = github.context.payload.pull_request) === null || _0 === void 0 ? void 0 : _0.base) === null || _1 === void 0 ? void 0 : _1.sha;
|
previousSha = (_z = (_y = github.context.payload.pull_request) === null || _y === void 0 ? void 0 : _y.base) === null || _z === void 0 ? void 0 : _z.sha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(yield (0, utils_1.canDiffCommits)({
|
if (!(yield (0, utils_1.canDiffCommits)({
|
||||||
|
@ -1714,7 +1709,7 @@ const env_1 = __nccwpck_require__(9763);
|
||||||
const inputs_1 = __nccwpck_require__(6180);
|
const inputs_1 = __nccwpck_require__(6180);
|
||||||
const utils_1 = __nccwpck_require__(918);
|
const utils_1 = __nccwpck_require__(918);
|
||||||
const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void 0, function* ({ inputs, env, workingDirectory, filePatterns, yamlFilePatterns }) {
|
const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void 0, function* ({ inputs, env, workingDirectory, filePatterns, yamlFilePatterns }) {
|
||||||
var _b, _c, _d, _e;
|
var _b, _c, _d;
|
||||||
yield (0, utils_1.verifyMinimumGitVersion)();
|
yield (0, utils_1.verifyMinimumGitVersion)();
|
||||||
let quotepathValue = 'on';
|
let quotepathValue = 'on';
|
||||||
if (!inputs.quotepath) {
|
if (!inputs.quotepath) {
|
||||||
|
@ -1737,8 +1732,7 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
||||||
gitFetchExtraArgs.push('--recurse-submodules');
|
gitFetchExtraArgs.push('--recurse-submodules');
|
||||||
}
|
}
|
||||||
const isTag = (_b = env.GITHUB_REF) === null || _b === void 0 ? void 0 : _b.startsWith('refs/tags/');
|
const isTag = (_b = env.GITHUB_REF) === null || _b === void 0 ? void 0 : _b.startsWith('refs/tags/');
|
||||||
const isFork = ((_c = github.context.payload.pull_request) === null || _c === void 0 ? void 0 : _c.head.repo.fork) || false;
|
const remoteName = 'origin';
|
||||||
let remoteName = 'origin';
|
|
||||||
const outputRenamedFilesAsDeletedAndAdded = inputs.outputRenamedFilesAsDeletedAndAdded;
|
const outputRenamedFilesAsDeletedAndAdded = inputs.outputRenamedFilesAsDeletedAndAdded;
|
||||||
let submodulePaths = [];
|
let submodulePaths = [];
|
||||||
if (hasSubmodule) {
|
if (hasSubmodule) {
|
||||||
|
@ -1747,11 +1741,8 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
||||||
if (isTag) {
|
if (isTag) {
|
||||||
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules'];
|
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules'];
|
||||||
}
|
}
|
||||||
if (isFork) {
|
|
||||||
remoteName = yield (0, utils_1.setForkRemote)({ cwd: workingDirectory });
|
|
||||||
}
|
|
||||||
let diffResult;
|
let diffResult;
|
||||||
if (!((_e = (_d = github.context.payload.pull_request) === null || _d === void 0 ? void 0 : _d.base) === null || _e === void 0 ? void 0 : _e.ref)) {
|
if (!((_d = (_c = github.context.payload.pull_request) === null || _c === void 0 ? void 0 : _c.base) === null || _d === void 0 ? void 0 : _d.ref)) {
|
||||||
core.info(`Running on a ${github.context.eventName || 'push'} event...`);
|
core.info(`Running on a ${github.context.eventName || 'push'} event...`);
|
||||||
diffResult = yield (0, commitSha_1.getSHAForNonPullRequestEvent)({
|
diffResult = yield (0, commitSha_1.getSHAForNonPullRequestEvent)({
|
||||||
inputs,
|
inputs,
|
||||||
|
@ -1772,8 +1763,7 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
gitFetchExtraArgs,
|
gitFetchExtraArgs,
|
||||||
remoteName,
|
remoteName
|
||||||
isFork
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (diffResult.initialCommit) {
|
if (diffResult.initialCommit) {
|
||||||
|
@ -1847,7 +1837,7 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const getChangedFilesFromRESTAPI = (_f) => __awaiter(void 0, [_f], void 0, function* ({ inputs, filePatterns, yamlFilePatterns }) {
|
const getChangedFilesFromRESTAPI = (_e) => __awaiter(void 0, [_e], void 0, function* ({ inputs, filePatterns, yamlFilePatterns }) {
|
||||||
const allDiffFiles = yield (0, changedFiles_1.getChangedFilesFromGithubAPI)({
|
const allDiffFiles = yield (0, changedFiles_1.getChangedFilesFromGithubAPI)({
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
|
@ -1986,7 +1976,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.warnUnsupportedRESTAPIInputs = exports.hasLocalGitDirectory = exports.recoverDeletedFiles = exports.setOutput = exports.setArrayOutput = exports.getOutputKey = exports.getRecoverFilePatterns = exports.getYamlFilePatterns = exports.getFilePatterns = exports.getDirNamesIncludeFilesPattern = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.cleanShaInput = exports.verifyCommitSha = exports.setForkRemote = exports.getParentSha = exports.getCurrentBranchName = exports.getRemoteBranchHeadSha = exports.isInsideWorkTree = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.exists = exports.verifyMinimumGitVersion = exports.getDirname = exports.normalizeSeparators = exports.isWindows = void 0;
|
exports.warnUnsupportedRESTAPIInputs = exports.hasLocalGitDirectory = exports.recoverDeletedFiles = exports.setOutput = exports.setArrayOutput = exports.getOutputKey = exports.getRecoverFilePatterns = exports.getYamlFilePatterns = exports.getFilePatterns = exports.getDirNamesIncludeFilesPattern = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.cleanShaInput = exports.verifyCommitSha = exports.getParentSha = exports.getCurrentBranchName = exports.getRemoteBranchHeadSha = exports.isInsideWorkTree = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.exists = exports.verifyMinimumGitVersion = exports.getDirname = exports.normalizeSeparators = exports.isWindows = void 0;
|
||||||
/*global AsyncIterableIterator*/
|
/*global AsyncIterableIterator*/
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const exec = __importStar(__nccwpck_require__(1514));
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
|
@ -2522,33 +2512,7 @@ const getParentSha = (_3) => __awaiter(void 0, [_3], void 0, function* ({ cwd })
|
||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
});
|
});
|
||||||
exports.getParentSha = getParentSha;
|
exports.getParentSha = getParentSha;
|
||||||
const remoteExists = (cwd, remoteName) => __awaiter(void 0, void 0, void 0, function* () {
|
const verifyCommitSha = (_4) => __awaiter(void 0, [_4], void 0, function* ({ sha, cwd, showAsErrorMessage = true }) {
|
||||||
const { exitCode } = yield exec.getExecOutput('git', ['remote', 'get-url', remoteName], {
|
|
||||||
cwd,
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: !core.isDebug()
|
|
||||||
});
|
|
||||||
return exitCode === 0;
|
|
||||||
});
|
|
||||||
const setForkRemote = (_4) => __awaiter(void 0, [_4], void 0, function* ({ cwd }) {
|
|
||||||
var _5;
|
|
||||||
const remoteName = 'changed-files-fork';
|
|
||||||
const remoteFound = yield remoteExists(cwd, remoteName);
|
|
||||||
if (!remoteFound) {
|
|
||||||
yield exec.getExecOutput('git', [
|
|
||||||
'remote',
|
|
||||||
'add',
|
|
||||||
remoteName,
|
|
||||||
(_5 = github.context.payload.repository) === null || _5 === void 0 ? void 0 : _5.clone_url
|
|
||||||
], {
|
|
||||||
cwd,
|
|
||||||
silent: !core.isDebug()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return remoteName;
|
|
||||||
});
|
|
||||||
exports.setForkRemote = setForkRemote;
|
|
||||||
const verifyCommitSha = (_6) => __awaiter(void 0, [_6], void 0, function* ({ sha, cwd, showAsErrorMessage = true }) {
|
|
||||||
const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--verify', `${sha}^{commit}`], {
|
const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--verify', `${sha}^{commit}`], {
|
||||||
cwd,
|
cwd,
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
|
@ -2580,7 +2544,7 @@ exports.verifyCommitSha = verifyCommitSha;
|
||||||
* @param token The GitHub token.
|
* @param token The GitHub token.
|
||||||
* @returns The cleaned SHA string.
|
* @returns The cleaned SHA string.
|
||||||
*/
|
*/
|
||||||
const cleanShaInput = (_7) => __awaiter(void 0, [_7], void 0, function* ({ sha, cwd, token }) {
|
const cleanShaInput = (_5) => __awaiter(void 0, [_5], void 0, function* ({ sha, cwd, token }) {
|
||||||
// Check if the input is a valid commit sha
|
// Check if the input is a valid commit sha
|
||||||
if (!sha) {
|
if (!sha) {
|
||||||
return sha;
|
return sha;
|
||||||
|
@ -2604,7 +2568,7 @@ const cleanShaInput = (_7) => __awaiter(void 0, [_7], void 0, function* ({ sha,
|
||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
});
|
});
|
||||||
exports.cleanShaInput = cleanShaInput;
|
exports.cleanShaInput = cleanShaInput;
|
||||||
const getPreviousGitTag = (_8) => __awaiter(void 0, [_8], void 0, function* ({ cwd }) {
|
const getPreviousGitTag = (_6) => __awaiter(void 0, [_6], void 0, function* ({ cwd }) {
|
||||||
const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-creatordate'], {
|
const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-creatordate'], {
|
||||||
cwd,
|
cwd,
|
||||||
silent: !core.isDebug()
|
silent: !core.isDebug()
|
||||||
|
@ -2623,7 +2587,7 @@ const getPreviousGitTag = (_8) => __awaiter(void 0, [_8], void 0, function* ({ c
|
||||||
return { tag: previousTag, sha };
|
return { tag: previousTag, sha };
|
||||||
});
|
});
|
||||||
exports.getPreviousGitTag = getPreviousGitTag;
|
exports.getPreviousGitTag = getPreviousGitTag;
|
||||||
const canDiffCommits = (_9) => __awaiter(void 0, [_9], void 0, function* ({ cwd, sha1, sha2, diff }) {
|
const canDiffCommits = (_7) => __awaiter(void 0, [_7], void 0, function* ({ cwd, sha1, sha2, diff }) {
|
||||||
if (diff === '...') {
|
if (diff === '...') {
|
||||||
const mergeBase = yield getMergeBase(cwd, sha1, sha2);
|
const mergeBase = yield getMergeBase(cwd, sha1, sha2);
|
||||||
if (!mergeBase) {
|
if (!mergeBase) {
|
||||||
|
@ -2690,7 +2654,7 @@ const getDirNamesIncludeFilesPattern = ({ inputs }) => {
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
};
|
};
|
||||||
exports.getDirNamesIncludeFilesPattern = getDirNamesIncludeFilesPattern;
|
exports.getDirNamesIncludeFilesPattern = getDirNamesIncludeFilesPattern;
|
||||||
const getFilePatterns = (_10) => __awaiter(void 0, [_10], void 0, function* ({ inputs, workingDirectory }) {
|
const getFilePatterns = (_8) => __awaiter(void 0, [_8], void 0, function* ({ inputs, workingDirectory }) {
|
||||||
let cleanedFilePatterns = [];
|
let cleanedFilePatterns = [];
|
||||||
if (inputs.files) {
|
if (inputs.files) {
|
||||||
const filesPatterns = inputs.files
|
const filesPatterns = inputs.files
|
||||||
|
@ -2757,7 +2721,7 @@ const getFilePatterns = (_10) => __awaiter(void 0, [_10], void 0, function* ({ i
|
||||||
return cleanedFilePatterns;
|
return cleanedFilePatterns;
|
||||||
});
|
});
|
||||||
exports.getFilePatterns = getFilePatterns;
|
exports.getFilePatterns = getFilePatterns;
|
||||||
const getYamlFilePatternsFromContents = (_11) => __awaiter(void 0, [_11], void 0, function* ({ content = '', filePath = '', excludedFiles = false }) {
|
const getYamlFilePatternsFromContents = (_9) => __awaiter(void 0, [_9], void 0, function* ({ content = '', filePath = '', excludedFiles = false }) {
|
||||||
const filePatterns = {};
|
const filePatterns = {};
|
||||||
let source = '';
|
let source = '';
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
|
@ -2814,7 +2778,7 @@ const getYamlFilePatternsFromContents = (_11) => __awaiter(void 0, [_11], void 0
|
||||||
}
|
}
|
||||||
return filePatterns;
|
return filePatterns;
|
||||||
});
|
});
|
||||||
const getYamlFilePatterns = (_12) => __awaiter(void 0, [_12], void 0, function* ({ inputs, workingDirectory }) {
|
const getYamlFilePatterns = (_10) => __awaiter(void 0, [_10], void 0, function* ({ inputs, workingDirectory }) {
|
||||||
let filePatterns = {};
|
let filePatterns = {};
|
||||||
if (inputs.filesYaml) {
|
if (inputs.filesYaml) {
|
||||||
filePatterns = Object.assign({}, (yield getYamlFilePatternsFromContents({ content: inputs.filesYaml })));
|
filePatterns = Object.assign({}, (yield getYamlFilePatternsFromContents({ content: inputs.filesYaml })));
|
||||||
|
@ -2889,7 +2853,7 @@ const getOutputKey = (key, outputPrefix) => {
|
||||||
return outputPrefix ? `${outputPrefix}_${key}` : key;
|
return outputPrefix ? `${outputPrefix}_${key}` : key;
|
||||||
};
|
};
|
||||||
exports.getOutputKey = getOutputKey;
|
exports.getOutputKey = getOutputKey;
|
||||||
const setArrayOutput = (_13) => __awaiter(void 0, [_13], void 0, function* ({ key, inputs, value, outputPrefix }) {
|
const setArrayOutput = (_11) => __awaiter(void 0, [_11], void 0, function* ({ key, inputs, value, outputPrefix }) {
|
||||||
core.debug(`${key}: ${JSON.stringify(value)}`);
|
core.debug(`${key}: ${JSON.stringify(value)}`);
|
||||||
yield (0, exports.setOutput)({
|
yield (0, exports.setOutput)({
|
||||||
key: outputPrefix ? (0, exports.getOutputKey)(key, outputPrefix) : key,
|
key: outputPrefix ? (0, exports.getOutputKey)(key, outputPrefix) : key,
|
||||||
|
@ -2902,7 +2866,7 @@ const setArrayOutput = (_13) => __awaiter(void 0, [_13], void 0, function* ({ ke
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
exports.setArrayOutput = setArrayOutput;
|
exports.setArrayOutput = setArrayOutput;
|
||||||
const setOutput = (_14) => __awaiter(void 0, [_14], void 0, function* ({ key, value, writeOutputFiles, outputDir, json = false, shouldEscape = false, safeOutput = false }) {
|
const setOutput = (_12) => __awaiter(void 0, [_12], void 0, function* ({ key, value, writeOutputFiles, outputDir, json = false, shouldEscape = false, safeOutput = false }) {
|
||||||
let cleanedValue;
|
let cleanedValue;
|
||||||
if (json) {
|
if (json) {
|
||||||
cleanedValue = (0, exports.jsonOutput)({ value, shouldEscape });
|
cleanedValue = (0, exports.jsonOutput)({ value, shouldEscape });
|
||||||
|
@ -2925,7 +2889,7 @@ const setOutput = (_14) => __awaiter(void 0, [_14], void 0, function* ({ key, va
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
exports.setOutput = setOutput;
|
exports.setOutput = setOutput;
|
||||||
const getDeletedFileContents = (_15) => __awaiter(void 0, [_15], void 0, function* ({ cwd, filePath, sha }) {
|
const getDeletedFileContents = (_13) => __awaiter(void 0, [_13], void 0, function* ({ cwd, filePath, sha }) {
|
||||||
const { stdout, exitCode, stderr } = yield exec.getExecOutput('git', ['show', `${sha}:${filePath}`], {
|
const { stdout, exitCode, stderr } = yield exec.getExecOutput('git', ['show', `${sha}:${filePath}`], {
|
||||||
cwd,
|
cwd,
|
||||||
silent: !core.isDebug(),
|
silent: !core.isDebug(),
|
||||||
|
@ -2936,7 +2900,7 @@ const getDeletedFileContents = (_15) => __awaiter(void 0, [_15], void 0, functio
|
||||||
}
|
}
|
||||||
return stdout;
|
return stdout;
|
||||||
});
|
});
|
||||||
const recoverDeletedFiles = (_16) => __awaiter(void 0, [_16], void 0, function* ({ inputs, workingDirectory, deletedFiles, recoverPatterns, diffResult, hasSubmodule, submodulePaths }) {
|
const recoverDeletedFiles = (_14) => __awaiter(void 0, [_14], void 0, function* ({ inputs, workingDirectory, deletedFiles, recoverPatterns, diffResult, hasSubmodule, submodulePaths }) {
|
||||||
let recoverableDeletedFiles = deletedFiles;
|
let recoverableDeletedFiles = deletedFiles;
|
||||||
core.debug(`recoverable deleted files: ${recoverableDeletedFiles}`);
|
core.debug(`recoverable deleted files: ${recoverableDeletedFiles}`);
|
||||||
if (recoverPatterns.length > 0) {
|
if (recoverPatterns.length > 0) {
|
||||||
|
@ -3001,7 +2965,7 @@ exports.recoverDeletedFiles = recoverDeletedFiles;
|
||||||
* @param workingDirectory - The path of the working directory.
|
* @param workingDirectory - The path of the working directory.
|
||||||
* @returns A boolean value indicating whether the working directory has a local Git directory.
|
* @returns A boolean value indicating whether the working directory has a local Git directory.
|
||||||
*/
|
*/
|
||||||
const hasLocalGitDirectory = (_17) => __awaiter(void 0, [_17], void 0, function* ({ workingDirectory }) {
|
const hasLocalGitDirectory = (_15) => __awaiter(void 0, [_15], void 0, function* ({ workingDirectory }) {
|
||||||
return yield (0, exports.isInsideWorkTree)({
|
return yield (0, exports.isInsideWorkTree)({
|
||||||
cwd: workingDirectory
|
cwd: workingDirectory
|
||||||
});
|
});
|
||||||
|
@ -3012,13 +2976,13 @@ exports.hasLocalGitDirectory = hasLocalGitDirectory;
|
||||||
*
|
*
|
||||||
* @param inputs - The inputs object.
|
* @param inputs - The inputs object.
|
||||||
*/
|
*/
|
||||||
const warnUnsupportedRESTAPIInputs = (_18) => __awaiter(void 0, [_18], void 0, function* ({ inputs }) {
|
const warnUnsupportedRESTAPIInputs = (_16) => __awaiter(void 0, [_16], void 0, function* ({ inputs }) {
|
||||||
var _19, _20;
|
var _17, _18;
|
||||||
for (const key of Object.keys(constant_1.DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS)) {
|
for (const key of Object.keys(constant_1.DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS)) {
|
||||||
const defaultValue = Object.hasOwnProperty.call(constant_1.DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS, key)
|
const defaultValue = Object.hasOwnProperty.call(constant_1.DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS, key)
|
||||||
? (_19 = constant_1.DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS[key]) === null || _19 === void 0 ? void 0 : _19.toString()
|
? (_17 = constant_1.DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS[key]) === null || _17 === void 0 ? void 0 : _17.toString()
|
||||||
: '';
|
: '';
|
||||||
if (defaultValue !== ((_20 = inputs[key]) === null || _20 === void 0 ? void 0 : _20.toString())) {
|
if (defaultValue !== ((_18 = inputs[key]) === null || _18 === void 0 ? void 0 : _18.toString())) {
|
||||||
core.warning(`Input "${(0, lodash_1.snakeCase)(key)}" is not supported when using GitHub's REST API to get changed files`);
|
core.warning(`Input "${(0, lodash_1.snakeCase)(key)}" is not supported when using GitHub's REST API to get changed files`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
@ -326,7 +326,6 @@ interface SHAForPullRequestEvent {
|
||||||
hasSubmodule: boolean
|
hasSubmodule: boolean
|
||||||
gitFetchExtraArgs: string[]
|
gitFetchExtraArgs: string[]
|
||||||
remoteName: string
|
remoteName: string
|
||||||
isFork: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSHAForPullRequestEvent = async ({
|
export const getSHAForPullRequestEvent = async ({
|
||||||
|
@ -335,8 +334,7 @@ export const getSHAForPullRequestEvent = async ({
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
gitFetchExtraArgs,
|
gitFetchExtraArgs,
|
||||||
remoteName,
|
remoteName
|
||||||
isFork
|
|
||||||
}: SHAForPullRequestEvent): Promise<DiffResult> => {
|
}: SHAForPullRequestEvent): Promise<DiffResult> => {
|
||||||
let targetBranch = github.context.payload.pull_request?.base?.ref
|
let targetBranch = github.context.payload.pull_request?.base?.ref
|
||||||
const currentBranch = github.context.payload.pull_request?.head?.ref
|
const currentBranch = github.context.payload.pull_request?.head?.ref
|
||||||
|
@ -507,18 +505,14 @@ export const getSHAForPullRequestEvent = async ({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (github.context.payload.action === 'closed' || isFork) {
|
previousSha = github.context.payload.pull_request?.base?.sha
|
||||||
previousSha = github.context.payload.pull_request?.base?.sha
|
|
||||||
} else {
|
if (!previousSha) {
|
||||||
previousSha = await getRemoteBranchHeadSha({
|
previousSha = await getRemoteBranchHeadSha({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
branch: targetBranch,
|
remoteName,
|
||||||
remoteName
|
branch: targetBranch
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!previousSha) {
|
|
||||||
previousSha = github.context.payload.pull_request?.base?.sha
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShallow) {
|
if (isShallow) {
|
||||||
|
|
11
src/main.ts
11
src/main.ts
|
@ -23,7 +23,6 @@ import {
|
||||||
hasLocalGitDirectory,
|
hasLocalGitDirectory,
|
||||||
isRepoShallow,
|
isRepoShallow,
|
||||||
recoverDeletedFiles,
|
recoverDeletedFiles,
|
||||||
setForkRemote,
|
|
||||||
setOutput,
|
setOutput,
|
||||||
submoduleExists,
|
submoduleExists,
|
||||||
updateGitGlobalConfig,
|
updateGitGlobalConfig,
|
||||||
|
@ -73,8 +72,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
||||||
}
|
}
|
||||||
|
|
||||||
const isTag = env.GITHUB_REF?.startsWith('refs/tags/')
|
const isTag = env.GITHUB_REF?.startsWith('refs/tags/')
|
||||||
const isFork = github.context.payload.pull_request?.head.repo.fork || false
|
const remoteName = 'origin'
|
||||||
let remoteName = 'origin'
|
|
||||||
const outputRenamedFilesAsDeletedAndAdded =
|
const outputRenamedFilesAsDeletedAndAdded =
|
||||||
inputs.outputRenamedFilesAsDeletedAndAdded
|
inputs.outputRenamedFilesAsDeletedAndAdded
|
||||||
let submodulePaths: string[] = []
|
let submodulePaths: string[] = []
|
||||||
|
@ -87,10 +85,6 @@ const getChangedFilesFromLocalGitHistory = async ({
|
||||||
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules']
|
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules']
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFork) {
|
|
||||||
remoteName = await setForkRemote({cwd: workingDirectory})
|
|
||||||
}
|
|
||||||
|
|
||||||
let diffResult: DiffResult
|
let diffResult: DiffResult
|
||||||
|
|
||||||
if (!github.context.payload.pull_request?.base?.ref) {
|
if (!github.context.payload.pull_request?.base?.ref) {
|
||||||
|
@ -117,8 +111,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
||||||
isShallow,
|
isShallow,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
gitFetchExtraArgs,
|
gitFetchExtraArgs,
|
||||||
remoteName,
|
remoteName
|
||||||
isFork
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
41
src/utils.ts
41
src/utils.ts
|
@ -744,47 +744,6 @@ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => {
|
||||||
return stdout.trim()
|
return stdout.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteExists = async (
|
|
||||||
cwd: string,
|
|
||||||
remoteName: string
|
|
||||||
): Promise<boolean> => {
|
|
||||||
const {exitCode} = await exec.getExecOutput(
|
|
||||||
'git',
|
|
||||||
['remote', 'get-url', remoteName],
|
|
||||||
{
|
|
||||||
cwd,
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: !core.isDebug()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
return exitCode === 0
|
|
||||||
}
|
|
||||||
|
|
||||||
export const setForkRemote = async ({cwd}: {cwd: string}): Promise<string> => {
|
|
||||||
const remoteName = 'changed-files-fork'
|
|
||||||
|
|
||||||
const remoteFound = await remoteExists(cwd, remoteName)
|
|
||||||
|
|
||||||
if (!remoteFound) {
|
|
||||||
await exec.getExecOutput(
|
|
||||||
'git',
|
|
||||||
[
|
|
||||||
'remote',
|
|
||||||
'add',
|
|
||||||
remoteName,
|
|
||||||
github.context.payload.repository?.clone_url
|
|
||||||
],
|
|
||||||
{
|
|
||||||
cwd,
|
|
||||||
silent: !core.isDebug()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return remoteName
|
|
||||||
}
|
|
||||||
|
|
||||||
export const verifyCommitSha = async ({
|
export const verifyCommitSha = async ({
|
||||||
sha,
|
sha,
|
||||||
cwd,
|
cwd,
|
||||||
|
|
Loading…
Add table
Reference in a new issue