fix: bug with inaccurate warnings (#1853)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
e0579abf95
commit
62f4729b5d
144
dist/index.js
generated
vendored
144
dist/index.js
generated
vendored
@ -157,7 +157,7 @@ const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, s
|
|||||||
diff
|
diff
|
||||||
}))) {
|
}))) {
|
||||||
let message = `Unable to use three dot diff for: ${submodulePath} submodule. Falling back to two dot diff. You can set 'fetch_additional_submodule_history: true' to fetch additional submodule history in order to use three dot diff`;
|
let message = `Unable to use three dot diff for: ${submodulePath} submodule. Falling back to two dot diff. You can set 'fetch_additional_submodule_history: true' to fetch additional submodule history in order to use three dot diff`;
|
||||||
if (inputs.fetchSubmoduleHistory) {
|
if (inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
message = `To fetch additional submodule history for: ${submodulePath} you can increase history depth using 'fetch_depth' input`;
|
message = `To fetch additional submodule history for: ${submodulePath} you can increase history depth using 'fetch_depth' input`;
|
||||||
}
|
}
|
||||||
core.info(message);
|
core.info(message);
|
||||||
@ -199,7 +199,7 @@ var ChangeTypeEnum;
|
|||||||
ChangeTypeEnum["Unmerged"] = "U";
|
ChangeTypeEnum["Unmerged"] = "U";
|
||||||
ChangeTypeEnum["Unknown"] = "X";
|
ChangeTypeEnum["Unknown"] = "X";
|
||||||
})(ChangeTypeEnum || (exports.ChangeTypeEnum = ChangeTypeEnum = {}));
|
})(ChangeTypeEnum || (exports.ChangeTypeEnum = ChangeTypeEnum = {}));
|
||||||
const getAllDiffFiles = ({ workingDirectory, hasSubmodule, diffResult, submodulePaths, outputRenamedFilesAsDeletedAndAdded, fetchSubmoduleHistory, failOnInitialDiffError, failOnSubmoduleDiffError }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getAllDiffFiles = ({ workingDirectory, hasSubmodule, diffResult, submodulePaths, outputRenamedFilesAsDeletedAndAdded, fetchAdditionalSubmoduleHistory, failOnInitialDiffError, failOnSubmoduleDiffError }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const files = yield (0, utils_1.getAllChangedFiles)({
|
const files = yield (0, utils_1.getAllChangedFiles)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
sha1: diffResult.previousSha,
|
sha1: diffResult.previousSha,
|
||||||
@ -227,7 +227,7 @@ const getAllDiffFiles = ({ workingDirectory, hasSubmodule, diffResult, submodule
|
|||||||
diff
|
diff
|
||||||
}))) {
|
}))) {
|
||||||
let message = `Set 'fetch_additional_submodule_history: true' to fetch additional submodule history for: ${submodulePath}`;
|
let message = `Set 'fetch_additional_submodule_history: true' to fetch additional submodule history for: ${submodulePath}`;
|
||||||
if (fetchSubmoduleHistory) {
|
if (fetchAdditionalSubmoduleHistory) {
|
||||||
message = `To fetch additional submodule history for: ${submodulePath} you can increase history depth using 'fetch_depth' input`;
|
message = `To fetch additional submodule history for: ${submodulePath} you can increase history depth using 'fetch_depth' input`;
|
||||||
}
|
}
|
||||||
core.warning(message);
|
core.warning(message);
|
||||||
@ -981,7 +981,7 @@ const getSHAForNonPullRequestEvent = (inputs, env, workingDirectory, isShallow,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
if (hasSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
yield (0, utils_1.gitFetchSubmodules)({
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -1170,7 +1170,7 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
if (hasSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
yield (0, utils_1.gitFetchSubmodules)({
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -1350,6 +1350,39 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
exports.getSHAForPullRequestEvent = getSHAForPullRequestEvent;
|
exports.getSHAForPullRequestEvent = getSHAForPullRequestEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2363:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.UNSUPPORTED_REST_API_INPUTS = void 0;
|
||||||
|
exports.UNSUPPORTED_REST_API_INPUTS = [
|
||||||
|
'sha',
|
||||||
|
'baseSha',
|
||||||
|
'since',
|
||||||
|
'until',
|
||||||
|
'path',
|
||||||
|
'quotepath',
|
||||||
|
'diffRelative',
|
||||||
|
'sinceLastRemoteCommit',
|
||||||
|
'recoverDeletedFiles',
|
||||||
|
'recoverDeletedFilesToDestination',
|
||||||
|
'recoverFiles',
|
||||||
|
'recoverFilesSeparator',
|
||||||
|
'recoverFilesIgnore',
|
||||||
|
'recoverFilesIgnoreSeparator',
|
||||||
|
'includeAllOldNewRenamedFiles',
|
||||||
|
'oldNewSeparator',
|
||||||
|
'oldNewFilesSeparator',
|
||||||
|
'skipInitialFetch',
|
||||||
|
'fetchAdditionalSubmoduleHistory',
|
||||||
|
'dirNamesDeletedFilesIncludeOnlyDeletedDirs'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 9763:
|
/***/ 9763:
|
||||||
@ -1491,7 +1524,7 @@ const getInputs = () => {
|
|||||||
const since = core.getInput('since', { required: false });
|
const since = core.getInput('since', { required: false });
|
||||||
const until = core.getInput('until', { required: false });
|
const until = core.getInput('until', { required: false });
|
||||||
const path = core.getInput('path', { required: false });
|
const path = core.getInput('path', { required: false });
|
||||||
const quotePath = core.getBooleanInput('quotepath', { required: false });
|
const quotepath = core.getBooleanInput('quotepath', { required: false });
|
||||||
const diffRelative = core.getBooleanInput('diff_relative', { required: false });
|
const diffRelative = core.getBooleanInput('diff_relative', { required: false });
|
||||||
const dirNames = core.getBooleanInput('dir_names', { required: false });
|
const dirNames = core.getBooleanInput('dir_names', { required: false });
|
||||||
const dirNamesMaxDepth = core.getInput('dir_names_max_depth', {
|
const dirNamesMaxDepth = core.getInput('dir_names_max_depth', {
|
||||||
@ -1538,7 +1571,7 @@ const getInputs = () => {
|
|||||||
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
||||||
required: false
|
required: false
|
||||||
});
|
});
|
||||||
const fetchSubmoduleHistory = core.getBooleanInput('fetch_additional_submodule_history', {
|
const fetchAdditionalSubmoduleHistory = core.getBooleanInput('fetch_additional_submodule_history', {
|
||||||
required: false
|
required: false
|
||||||
});
|
});
|
||||||
const failOnInitialDiffError = core.getBooleanInput('fail_on_initial_diff_error', {
|
const failOnInitialDiffError = core.getBooleanInput('fail_on_initial_diff_error', {
|
||||||
@ -1580,7 +1613,7 @@ const getInputs = () => {
|
|||||||
since,
|
since,
|
||||||
until,
|
until,
|
||||||
path,
|
path,
|
||||||
quotePath,
|
quotepath,
|
||||||
diffRelative,
|
diffRelative,
|
||||||
sinceLastRemoteCommit,
|
sinceLastRemoteCommit,
|
||||||
recoverDeletedFiles,
|
recoverDeletedFiles,
|
||||||
@ -1593,7 +1626,7 @@ const getInputs = () => {
|
|||||||
oldNewSeparator,
|
oldNewSeparator,
|
||||||
oldNewFilesSeparator,
|
oldNewFilesSeparator,
|
||||||
skipInitialFetch,
|
skipInitialFetch,
|
||||||
fetchSubmoduleHistory,
|
fetchAdditionalSubmoduleHistory,
|
||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
||||||
// End Not Supported via REST API
|
// End Not Supported via REST API
|
||||||
dirNames,
|
dirNames,
|
||||||
@ -1677,13 +1710,13 @@ const utils_1 = __nccwpck_require__(918);
|
|||||||
const getChangedFilesFromLocalGitHistory = ({ inputs, env, workingDirectory, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getChangedFilesFromLocalGitHistory = ({ inputs, env, workingDirectory, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
yield (0, utils_1.verifyMinimumGitVersion)();
|
yield (0, utils_1.verifyMinimumGitVersion)();
|
||||||
let quotePathValue = 'on';
|
let quotepathValue = 'on';
|
||||||
if (!inputs.quotePath) {
|
if (!inputs.quotepath) {
|
||||||
quotePathValue = 'off';
|
quotepathValue = 'off';
|
||||||
}
|
}
|
||||||
yield (0, utils_1.updateGitGlobalConfig)({
|
yield (0, utils_1.updateGitGlobalConfig)({
|
||||||
name: 'core.quotepath',
|
name: 'core.quotepath',
|
||||||
value: quotePathValue
|
value: quotepathValue
|
||||||
});
|
});
|
||||||
if (inputs.diffRelative) {
|
if (inputs.diffRelative) {
|
||||||
yield (0, utils_1.updateGitGlobalConfig)({
|
yield (0, utils_1.updateGitGlobalConfig)({
|
||||||
@ -1724,7 +1757,7 @@ const getChangedFilesFromLocalGitHistory = ({ inputs, env, workingDirectory, fil
|
|||||||
diffResult,
|
diffResult,
|
||||||
submodulePaths,
|
submodulePaths,
|
||||||
outputRenamedFilesAsDeletedAndAdded,
|
outputRenamedFilesAsDeletedAndAdded,
|
||||||
fetchSubmoduleHistory: inputs.fetchSubmoduleHistory,
|
fetchAdditionalSubmoduleHistory: inputs.fetchAdditionalSubmoduleHistory,
|
||||||
failOnInitialDiffError: inputs.failOnInitialDiffError,
|
failOnInitialDiffError: inputs.failOnInitialDiffError,
|
||||||
failOnSubmoduleDiffError: inputs.failOnSubmoduleDiffError
|
failOnSubmoduleDiffError: inputs.failOnSubmoduleDiffError
|
||||||
});
|
});
|
||||||
@ -1826,32 +1859,11 @@ function run() {
|
|||||||
((_b = github.context.payload.pull_request) === null || _b === void 0 ? void 0 : _b.number) &&
|
((_b = github.context.payload.pull_request) === null || _b === void 0 ? void 0 : _b.number) &&
|
||||||
(!hasGitDirectory || inputs.useRestApi)) {
|
(!hasGitDirectory || inputs.useRestApi)) {
|
||||||
core.info("Using GitHub's REST API to get changed files");
|
core.info("Using GitHub's REST API to get changed files");
|
||||||
const unsupportedInputs = [
|
if (process.env.GITHUB_ACTION_PATH) {
|
||||||
'sha',
|
yield (0, utils_1.warnUnsupportedRESTAPIInputs)({
|
||||||
'baseSha',
|
actionPath: process.env.GITHUB_ACTION_PATH,
|
||||||
'since',
|
inputs
|
||||||
'until',
|
});
|
||||||
'path',
|
|
||||||
'quotePath',
|
|
||||||
'diffRelative',
|
|
||||||
'sinceLastRemoteCommit',
|
|
||||||
'recoverDeletedFiles',
|
|
||||||
'recoverDeletedFilesToDestination',
|
|
||||||
'recoverFiles',
|
|
||||||
'recoverFilesSeparator',
|
|
||||||
'recoverFilesIgnore',
|
|
||||||
'recoverFilesIgnoreSeparator',
|
|
||||||
'includeAllOldNewRenamedFiles',
|
|
||||||
'oldNewSeparator',
|
|
||||||
'oldNewFilesSeparator',
|
|
||||||
'skipInitialFetch',
|
|
||||||
'fetchSubmoduleHistory',
|
|
||||||
'dirNamesDeletedFilesIncludeOnlyDeletedDirs'
|
|
||||||
];
|
|
||||||
for (const input of unsupportedInputs) {
|
|
||||||
if (inputs[input]) {
|
|
||||||
core.warning(`Input "${input}" is not supported when using GitHub's REST API to get changed files`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
yield getChangedFilesFromRESTAPI({
|
yield getChangedFilesFromRESTAPI({
|
||||||
inputs,
|
inputs,
|
||||||
@ -1949,19 +1961,19 @@ 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.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;
|
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));
|
||||||
const github = __importStar(__nccwpck_require__(5438));
|
const github = __importStar(__nccwpck_require__(5438));
|
||||||
const fs_1 = __nccwpck_require__(7147);
|
const fs_1 = __nccwpck_require__(7147);
|
||||||
const promises_1 = __nccwpck_require__(3292);
|
|
||||||
const lodash_1 = __nccwpck_require__(250);
|
const lodash_1 = __nccwpck_require__(250);
|
||||||
const micromatch_1 = __importDefault(__nccwpck_require__(6228));
|
const micromatch_1 = __importDefault(__nccwpck_require__(6228));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const readline_1 = __nccwpck_require__(4521);
|
const readline_1 = __nccwpck_require__(4521);
|
||||||
const yaml_1 = __nccwpck_require__(4083);
|
const yaml_1 = __nccwpck_require__(4083);
|
||||||
const changedFiles_1 = __nccwpck_require__(7358);
|
const changedFiles_1 = __nccwpck_require__(7358);
|
||||||
|
const constant_1 = __nccwpck_require__(2363);
|
||||||
const MINIMUM_GIT_VERSION = '2.18.0';
|
const MINIMUM_GIT_VERSION = '2.18.0';
|
||||||
const isWindows = () => {
|
const isWindows = () => {
|
||||||
return process.platform === 'win32';
|
return process.platform === 'win32';
|
||||||
@ -2202,6 +2214,7 @@ exports.submoduleExists = submoduleExists;
|
|||||||
* Fetches the git repository
|
* Fetches the git repository
|
||||||
* @param args - arguments for fetch command
|
* @param args - arguments for fetch command
|
||||||
* @param cwd - working directory
|
* @param cwd - working directory
|
||||||
|
* @returns exit code
|
||||||
*/
|
*/
|
||||||
const gitFetch = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
const gitFetch = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const { exitCode } = yield exec.getExecOutput('git', ['fetch', '-q', ...args], {
|
const { exitCode } = yield exec.getExecOutput('git', ['fetch', '-q', ...args], {
|
||||||
@ -2232,6 +2245,7 @@ exports.gitFetchSubmodules = gitFetchSubmodules;
|
|||||||
/**
|
/**
|
||||||
* Retrieves all the submodule paths
|
* Retrieves all the submodule paths
|
||||||
* @param cwd - working directory
|
* @param cwd - working directory
|
||||||
|
* @returns submodule paths
|
||||||
*/
|
*/
|
||||||
const getSubmodulePath = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getSubmodulePath = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], {
|
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], {
|
||||||
@ -2256,6 +2270,7 @@ exports.getSubmodulePath = getSubmodulePath;
|
|||||||
* @param parentSha2 - parent commit sha
|
* @param parentSha2 - parent commit sha
|
||||||
* @param submodulePath - path of submodule
|
* @param submodulePath - path of submodule
|
||||||
* @param diff - diff type between parent commits (`..` or `...`)
|
* @param diff - diff type between parent commits (`..` or `...`)
|
||||||
|
* @returns commit sha of submodule
|
||||||
*/
|
*/
|
||||||
const gitSubmoduleDiffSHA = ({ cwd, parentSha1, parentSha2, submodulePath, diff }) => __awaiter(void 0, void 0, void 0, function* () {
|
const gitSubmoduleDiffSHA = ({ cwd, parentSha1, parentSha2, submodulePath, diff }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
var _h, _j, _k, _l;
|
var _h, _j, _k, _l;
|
||||||
@ -2697,7 +2712,7 @@ const getYamlFilePatternsFromContents = ({ content = '', filePath = '', excluded
|
|||||||
core.error(`File does not exist: ${filePath}`);
|
core.error(`File does not exist: ${filePath}`);
|
||||||
throw new Error(`File does not exist: ${filePath}`);
|
throw new Error(`File does not exist: ${filePath}`);
|
||||||
}
|
}
|
||||||
source = yield (0, promises_1.readFile)(filePath, 'utf8');
|
source = yield fs_1.promises.readFile(filePath, 'utf8');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
source = content;
|
source = content;
|
||||||
@ -2927,12 +2942,47 @@ const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, recoverPa
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
exports.recoverDeletedFiles = recoverDeletedFiles;
|
exports.recoverDeletedFiles = recoverDeletedFiles;
|
||||||
|
/**
|
||||||
|
* Determines whether the specified working directory has a local Git directory.
|
||||||
|
*
|
||||||
|
* @param workingDirectory - The path of the working directory.
|
||||||
|
* @returns A boolean value indicating whether the working directory has a local Git directory.
|
||||||
|
*/
|
||||||
const hasLocalGitDirectory = ({ workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
const hasLocalGitDirectory = ({ workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
return yield (0, exports.isInsideWorkTree)({
|
return yield (0, exports.isInsideWorkTree)({
|
||||||
cwd: workingDirectory
|
cwd: workingDirectory
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
exports.hasLocalGitDirectory = hasLocalGitDirectory;
|
exports.hasLocalGitDirectory = hasLocalGitDirectory;
|
||||||
|
/**
|
||||||
|
* Warns about unsupported inputs when using the REST API.
|
||||||
|
*
|
||||||
|
* @param actionPath - The path to the action file.
|
||||||
|
* @param inputs - The inputs object.
|
||||||
|
*/
|
||||||
|
const warnUnsupportedRESTAPIInputs = ({ actionPath, inputs }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
var _m;
|
||||||
|
const actionContents = yield fs_1.promises.readFile(actionPath, 'utf8');
|
||||||
|
const actionYaml = (0, yaml_1.parseDocument)(actionContents, { schema: 'failsafe' });
|
||||||
|
if (actionYaml.errors.length > 0) {
|
||||||
|
throw new Error(`YAML errors in ${actionPath}: ${actionYaml.errors.join(', ')}`);
|
||||||
|
}
|
||||||
|
if (actionYaml.warnings.length > 0) {
|
||||||
|
throw new Error(`YAML warnings in ${actionPath}: ${actionYaml.warnings.join(', ')}`);
|
||||||
|
}
|
||||||
|
const action = actionYaml.toJS();
|
||||||
|
const actionInputs = action.inputs;
|
||||||
|
for (const key of constant_1.UNSUPPORTED_REST_API_INPUTS) {
|
||||||
|
const inputKey = (0, lodash_1.snakeCase)(key);
|
||||||
|
const defaultValue = Object.hasOwnProperty.call(actionInputs[inputKey], 'default')
|
||||||
|
? actionInputs[inputKey].default.toString()
|
||||||
|
: '';
|
||||||
|
if (defaultValue !== ((_m = inputs[key]) === null || _m === void 0 ? void 0 : _m.toString())) {
|
||||||
|
core.warning(`Input "${inputKey}" is not supported when using GitHub's REST API to get changed files`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
exports.warnUnsupportedRESTAPIInputs = warnUnsupportedRESTAPIInputs;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -54886,14 +54936,6 @@ module.exports = require("fs");
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 3292:
|
|
||||||
/***/ ((module) => {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
module.exports = require("fs/promises");
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 3685:
|
/***/ 3685:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
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
@ -1,12 +1,18 @@
|
|||||||
|
import * as core from '@actions/core'
|
||||||
|
import {promises as fs} from 'fs'
|
||||||
|
import path from 'path'
|
||||||
import {ChangeTypeEnum} from '../changedFiles'
|
import {ChangeTypeEnum} from '../changedFiles'
|
||||||
|
import {Inputs} from '../inputs'
|
||||||
import {
|
import {
|
||||||
getDirname,
|
getDirname,
|
||||||
getDirnameMaxDepth,
|
getDirnameMaxDepth,
|
||||||
getFilteredChangedFiles,
|
getFilteredChangedFiles,
|
||||||
normalizeSeparators
|
normalizeSeparators,
|
||||||
|
warnUnsupportedRESTAPIInputs
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
|
|
||||||
const originalPlatform = process.platform
|
const originalPlatform = process.platform
|
||||||
|
const ACTION_PATH = path.resolve(__dirname, '..', '..', 'action.yml')
|
||||||
|
|
||||||
function mockedPlatform(platform: string): void {
|
function mockedPlatform(platform: string): void {
|
||||||
Object.defineProperty(process, 'platform', {
|
Object.defineProperty(process, 'platform', {
|
||||||
@ -575,4 +581,160 @@ describe('utils test', () => {
|
|||||||
expect(filteredFiles[ChangeTypeEnum.Modified]).toEqual([])
|
expect(filteredFiles[ChangeTypeEnum.Modified]).toEqual([])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('warnUnsupportedRESTAPIInputs', () => {
|
||||||
|
// Warns about unsupported inputs when using the REST API.
|
||||||
|
it('should warn about unsupported inputs when all inputs are supported', async () => {
|
||||||
|
const inputs: Inputs = {
|
||||||
|
files: '',
|
||||||
|
filesSeparator: '\n',
|
||||||
|
filesFromSourceFile: '',
|
||||||
|
filesFromSourceFileSeparator: '\n',
|
||||||
|
filesYaml: '',
|
||||||
|
filesYamlFromSourceFile: '',
|
||||||
|
filesYamlFromSourceFileSeparator: '\n',
|
||||||
|
filesIgnore: '',
|
||||||
|
filesIgnoreSeparator: '\n',
|
||||||
|
filesIgnoreFromSourceFile: '',
|
||||||
|
filesIgnoreFromSourceFileSeparator: '\n',
|
||||||
|
filesIgnoreYaml: '',
|
||||||
|
filesIgnoreYamlFromSourceFile: '',
|
||||||
|
filesIgnoreYamlFromSourceFileSeparator: '\n',
|
||||||
|
separator: ' ',
|
||||||
|
includeAllOldNewRenamedFiles: false,
|
||||||
|
oldNewSeparator: ',',
|
||||||
|
oldNewFilesSeparator: ' ',
|
||||||
|
sha: '1313123',
|
||||||
|
baseSha: '',
|
||||||
|
since: '',
|
||||||
|
until: '',
|
||||||
|
path: '.',
|
||||||
|
quotepath: true,
|
||||||
|
diffRelative: true,
|
||||||
|
dirNames: false,
|
||||||
|
dirNamesMaxDepth: undefined,
|
||||||
|
dirNamesExcludeCurrentDir: false,
|
||||||
|
dirNamesIncludeFiles: '',
|
||||||
|
dirNamesIncludeFilesSeparator: '\n',
|
||||||
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
|
||||||
|
json: false,
|
||||||
|
escapeJson: true,
|
||||||
|
safeOutput: true,
|
||||||
|
fetchDepth: 50,
|
||||||
|
fetchAdditionalSubmoduleHistory: false,
|
||||||
|
sinceLastRemoteCommit: false,
|
||||||
|
writeOutputFiles: false,
|
||||||
|
outputDir: '.github/outputs',
|
||||||
|
outputRenamedFilesAsDeletedAndAdded: false,
|
||||||
|
recoverDeletedFiles: false,
|
||||||
|
recoverDeletedFilesToDestination: '',
|
||||||
|
recoverFiles: '',
|
||||||
|
recoverFilesSeparator: '\n',
|
||||||
|
recoverFilesIgnore: '',
|
||||||
|
recoverFilesIgnoreSeparator: '\n',
|
||||||
|
token: '${{ github.token }}',
|
||||||
|
apiUrl: '${{ github.api_url }}',
|
||||||
|
skipInitialFetch: false,
|
||||||
|
failOnInitialDiffError: false,
|
||||||
|
failOnSubmoduleDiffError: false,
|
||||||
|
negationPatternsFirst: false,
|
||||||
|
useRestApi: false
|
||||||
|
}
|
||||||
|
|
||||||
|
const coreWarningSpy = jest.spyOn(core, 'warning')
|
||||||
|
|
||||||
|
await warnUnsupportedRESTAPIInputs({
|
||||||
|
actionPath: ACTION_PATH,
|
||||||
|
inputs
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(coreWarningSpy).toHaveBeenCalledWith(
|
||||||
|
'Input "sha" is not supported when using GitHub\'s REST API to get changed files'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Throws an error if there are YAML errors in the action file.
|
||||||
|
it('should throw an error if there are YAML errors in the action file', async () => {
|
||||||
|
const actionPath = './path/to/action.yml'
|
||||||
|
const inputs: Inputs = {
|
||||||
|
files: '',
|
||||||
|
filesSeparator: '\n',
|
||||||
|
filesFromSourceFile: '',
|
||||||
|
filesFromSourceFileSeparator: '\n',
|
||||||
|
filesYaml: '',
|
||||||
|
filesYamlFromSourceFile: '',
|
||||||
|
filesYamlFromSourceFileSeparator: '\n',
|
||||||
|
filesIgnore: '',
|
||||||
|
filesIgnoreSeparator: '\n',
|
||||||
|
filesIgnoreFromSourceFile: '',
|
||||||
|
filesIgnoreFromSourceFileSeparator: '\n',
|
||||||
|
filesIgnoreYaml: '',
|
||||||
|
filesIgnoreYamlFromSourceFile: '',
|
||||||
|
filesIgnoreYamlFromSourceFileSeparator: '\n',
|
||||||
|
separator: ' ',
|
||||||
|
includeAllOldNewRenamedFiles: false,
|
||||||
|
oldNewSeparator: ',',
|
||||||
|
oldNewFilesSeparator: ' ',
|
||||||
|
sha: '1313123',
|
||||||
|
baseSha: '',
|
||||||
|
since: '',
|
||||||
|
until: '',
|
||||||
|
path: '.',
|
||||||
|
quotepath: true,
|
||||||
|
diffRelative: true,
|
||||||
|
dirNames: false,
|
||||||
|
dirNamesMaxDepth: undefined,
|
||||||
|
dirNamesExcludeCurrentDir: false,
|
||||||
|
dirNamesIncludeFiles: '',
|
||||||
|
dirNamesIncludeFilesSeparator: '\n',
|
||||||
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
|
||||||
|
json: false,
|
||||||
|
escapeJson: true,
|
||||||
|
safeOutput: true,
|
||||||
|
fetchDepth: 50,
|
||||||
|
fetchAdditionalSubmoduleHistory: false,
|
||||||
|
sinceLastRemoteCommit: false,
|
||||||
|
writeOutputFiles: false,
|
||||||
|
outputDir: '.github/outputs',
|
||||||
|
outputRenamedFilesAsDeletedAndAdded: false,
|
||||||
|
recoverDeletedFiles: false,
|
||||||
|
recoverDeletedFilesToDestination: '',
|
||||||
|
recoverFiles: '',
|
||||||
|
recoverFilesSeparator: '\n',
|
||||||
|
recoverFilesIgnore: '',
|
||||||
|
recoverFilesIgnoreSeparator: '\n',
|
||||||
|
token: '${{ github.token }}',
|
||||||
|
apiUrl: '${{ github.api_url }}',
|
||||||
|
skipInitialFetch: false,
|
||||||
|
failOnInitialDiffError: false,
|
||||||
|
failOnSubmoduleDiffError: false,
|
||||||
|
negationPatternsFirst: false,
|
||||||
|
useRestApi: false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mocking readFile to return action file contents with errors
|
||||||
|
jest.spyOn(fs, 'readFile').mockResolvedValue(`
|
||||||
|
inputs:
|
||||||
|
files:
|
||||||
|
description: Files
|
||||||
|
required: true
|
||||||
|
default: ""
|
||||||
|
sha:
|
||||||
|
description: SHA
|
||||||
|
required: true
|
||||||
|
default: abc123
|
||||||
|
token:
|
||||||
|
description: Token
|
||||||
|
required: true
|
||||||
|
default: my-token
|
||||||
|
warnings:
|
||||||
|
| Invalid input value`)
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
warnUnsupportedRESTAPIInputs({actionPath, inputs})
|
||||||
|
).rejects.toThrow(
|
||||||
|
/YAML errors in .\/path\/to\/action.yml: YAMLParseError: Not a YAML token: Invalid input value at line 16, column 13:/
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -166,7 +166,7 @@ export const getRenamedFiles = async ({
|
|||||||
}))
|
}))
|
||||||
) {
|
) {
|
||||||
let message = `Unable to use three dot diff for: ${submodulePath} submodule. Falling back to two dot diff. You can set 'fetch_additional_submodule_history: true' to fetch additional submodule history in order to use three dot diff`
|
let message = `Unable to use three dot diff for: ${submodulePath} submodule. Falling back to two dot diff. You can set 'fetch_additional_submodule_history: true' to fetch additional submodule history in order to use three dot diff`
|
||||||
if (inputs.fetchSubmoduleHistory) {
|
if (inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
message = `To fetch additional submodule history for: ${submodulePath} you can increase history depth using 'fetch_depth' input`
|
message = `To fetch additional submodule history for: ${submodulePath} you can increase history depth using 'fetch_depth' input`
|
||||||
}
|
}
|
||||||
core.info(message)
|
core.info(message)
|
||||||
@ -221,7 +221,7 @@ export const getAllDiffFiles = async ({
|
|||||||
diffResult,
|
diffResult,
|
||||||
submodulePaths,
|
submodulePaths,
|
||||||
outputRenamedFilesAsDeletedAndAdded,
|
outputRenamedFilesAsDeletedAndAdded,
|
||||||
fetchSubmoduleHistory,
|
fetchAdditionalSubmoduleHistory,
|
||||||
failOnInitialDiffError,
|
failOnInitialDiffError,
|
||||||
failOnSubmoduleDiffError
|
failOnSubmoduleDiffError
|
||||||
}: {
|
}: {
|
||||||
@ -230,7 +230,7 @@ export const getAllDiffFiles = async ({
|
|||||||
diffResult: DiffResult
|
diffResult: DiffResult
|
||||||
submodulePaths: string[]
|
submodulePaths: string[]
|
||||||
outputRenamedFilesAsDeletedAndAdded: boolean
|
outputRenamedFilesAsDeletedAndAdded: boolean
|
||||||
fetchSubmoduleHistory: boolean
|
fetchAdditionalSubmoduleHistory: boolean
|
||||||
failOnInitialDiffError: boolean
|
failOnInitialDiffError: boolean
|
||||||
failOnSubmoduleDiffError: boolean
|
failOnSubmoduleDiffError: boolean
|
||||||
}): Promise<ChangedFiles> => {
|
}): Promise<ChangedFiles> => {
|
||||||
@ -270,7 +270,7 @@ export const getAllDiffFiles = async ({
|
|||||||
}))
|
}))
|
||||||
) {
|
) {
|
||||||
let message = `Set 'fetch_additional_submodule_history: true' to fetch additional submodule history for: ${submodulePath}`
|
let message = `Set 'fetch_additional_submodule_history: true' to fetch additional submodule history for: ${submodulePath}`
|
||||||
if (fetchSubmoduleHistory) {
|
if (fetchAdditionalSubmoduleHistory) {
|
||||||
message = `To fetch additional submodule history for: ${submodulePath} you can increase history depth using 'fetch_depth' input`
|
message = `To fetch additional submodule history for: ${submodulePath} you can increase history depth using 'fetch_depth' input`
|
||||||
}
|
}
|
||||||
core.warning(message)
|
core.warning(message)
|
||||||
|
@ -152,7 +152,7 @@ export const getSHAForNonPullRequestEvent = async (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
if (hasSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
await gitFetchSubmodules({
|
await gitFetchSubmodules({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -382,7 +382,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
if (hasSubmodule && inputs.fetchAdditionalSubmoduleHistory) {
|
||||||
await gitFetchSubmodules({
|
await gitFetchSubmodules({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
|
24
src/constant.ts
Normal file
24
src/constant.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import {Inputs} from './inputs'
|
||||||
|
|
||||||
|
export const UNSUPPORTED_REST_API_INPUTS: (keyof Inputs)[] = [
|
||||||
|
'sha',
|
||||||
|
'baseSha',
|
||||||
|
'since',
|
||||||
|
'until',
|
||||||
|
'path',
|
||||||
|
'quotepath',
|
||||||
|
'diffRelative',
|
||||||
|
'sinceLastRemoteCommit',
|
||||||
|
'recoverDeletedFiles',
|
||||||
|
'recoverDeletedFilesToDestination',
|
||||||
|
'recoverFiles',
|
||||||
|
'recoverFilesSeparator',
|
||||||
|
'recoverFilesIgnore',
|
||||||
|
'recoverFilesIgnoreSeparator',
|
||||||
|
'includeAllOldNewRenamedFiles',
|
||||||
|
'oldNewSeparator',
|
||||||
|
'oldNewFilesSeparator',
|
||||||
|
'skipInitialFetch',
|
||||||
|
'fetchAdditionalSubmoduleHistory',
|
||||||
|
'dirNamesDeletedFilesIncludeOnlyDeletedDirs'
|
||||||
|
]
|
@ -24,7 +24,7 @@ export type Inputs = {
|
|||||||
since: string
|
since: string
|
||||||
until: string
|
until: string
|
||||||
path: string
|
path: string
|
||||||
quotePath: boolean
|
quotepath: boolean
|
||||||
diffRelative: boolean
|
diffRelative: boolean
|
||||||
dirNames: boolean
|
dirNames: boolean
|
||||||
dirNamesMaxDepth?: number
|
dirNamesMaxDepth?: number
|
||||||
@ -36,7 +36,7 @@ export type Inputs = {
|
|||||||
escapeJson: boolean
|
escapeJson: boolean
|
||||||
safeOutput: boolean
|
safeOutput: boolean
|
||||||
fetchDepth?: number
|
fetchDepth?: number
|
||||||
fetchSubmoduleHistory: boolean
|
fetchAdditionalSubmoduleHistory: boolean
|
||||||
sinceLastRemoteCommit: boolean
|
sinceLastRemoteCommit: boolean
|
||||||
writeOutputFiles: boolean
|
writeOutputFiles: boolean
|
||||||
outputDir: string
|
outputDir: string
|
||||||
@ -132,7 +132,7 @@ export const getInputs = (): Inputs => {
|
|||||||
const since = core.getInput('since', {required: false})
|
const since = core.getInput('since', {required: false})
|
||||||
const until = core.getInput('until', {required: false})
|
const until = core.getInput('until', {required: false})
|
||||||
const path = core.getInput('path', {required: false})
|
const path = core.getInput('path', {required: false})
|
||||||
const quotePath = core.getBooleanInput('quotepath', {required: false})
|
const quotepath = core.getBooleanInput('quotepath', {required: false})
|
||||||
const diffRelative = core.getBooleanInput('diff_relative', {required: false})
|
const diffRelative = core.getBooleanInput('diff_relative', {required: false})
|
||||||
const dirNames = core.getBooleanInput('dir_names', {required: false})
|
const dirNames = core.getBooleanInput('dir_names', {required: false})
|
||||||
const dirNamesMaxDepth = core.getInput('dir_names_max_depth', {
|
const dirNamesMaxDepth = core.getInput('dir_names_max_depth', {
|
||||||
@ -197,7 +197,7 @@ export const getInputs = (): Inputs => {
|
|||||||
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
||||||
required: false
|
required: false
|
||||||
})
|
})
|
||||||
const fetchSubmoduleHistory = core.getBooleanInput(
|
const fetchAdditionalSubmoduleHistory = core.getBooleanInput(
|
||||||
'fetch_additional_submodule_history',
|
'fetch_additional_submodule_history',
|
||||||
{
|
{
|
||||||
required: false
|
required: false
|
||||||
@ -257,7 +257,7 @@ export const getInputs = (): Inputs => {
|
|||||||
since,
|
since,
|
||||||
until,
|
until,
|
||||||
path,
|
path,
|
||||||
quotePath,
|
quotepath,
|
||||||
diffRelative,
|
diffRelative,
|
||||||
sinceLastRemoteCommit,
|
sinceLastRemoteCommit,
|
||||||
recoverDeletedFiles,
|
recoverDeletedFiles,
|
||||||
@ -270,7 +270,7 @@ export const getInputs = (): Inputs => {
|
|||||||
oldNewSeparator,
|
oldNewSeparator,
|
||||||
oldNewFilesSeparator,
|
oldNewFilesSeparator,
|
||||||
skipInitialFetch,
|
skipInitialFetch,
|
||||||
fetchSubmoduleHistory,
|
fetchAdditionalSubmoduleHistory,
|
||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
||||||
// End Not Supported via REST API
|
// End Not Supported via REST API
|
||||||
dirNames,
|
dirNames,
|
||||||
|
47
src/main.ts
47
src/main.ts
@ -26,7 +26,8 @@ import {
|
|||||||
setOutput,
|
setOutput,
|
||||||
submoduleExists,
|
submoduleExists,
|
||||||
updateGitGlobalConfig,
|
updateGitGlobalConfig,
|
||||||
verifyMinimumGitVersion
|
verifyMinimumGitVersion,
|
||||||
|
warnUnsupportedRESTAPIInputs
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
const getChangedFilesFromLocalGitHistory = async ({
|
const getChangedFilesFromLocalGitHistory = async ({
|
||||||
@ -44,15 +45,15 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
}): Promise<void> => {
|
}): Promise<void> => {
|
||||||
await verifyMinimumGitVersion()
|
await verifyMinimumGitVersion()
|
||||||
|
|
||||||
let quotePathValue = 'on'
|
let quotepathValue = 'on'
|
||||||
|
|
||||||
if (!inputs.quotePath) {
|
if (!inputs.quotepath) {
|
||||||
quotePathValue = 'off'
|
quotepathValue = 'off'
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateGitGlobalConfig({
|
await updateGitGlobalConfig({
|
||||||
name: 'core.quotepath',
|
name: 'core.quotepath',
|
||||||
value: quotePathValue
|
value: quotepathValue
|
||||||
})
|
})
|
||||||
|
|
||||||
if (inputs.diffRelative) {
|
if (inputs.diffRelative) {
|
||||||
@ -123,7 +124,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
diffResult,
|
diffResult,
|
||||||
submodulePaths,
|
submodulePaths,
|
||||||
outputRenamedFilesAsDeletedAndAdded,
|
outputRenamedFilesAsDeletedAndAdded,
|
||||||
fetchSubmoduleHistory: inputs.fetchSubmoduleHistory,
|
fetchAdditionalSubmoduleHistory: inputs.fetchAdditionalSubmoduleHistory,
|
||||||
failOnInitialDiffError: inputs.failOnInitialDiffError,
|
failOnInitialDiffError: inputs.failOnInitialDiffError,
|
||||||
failOnSubmoduleDiffError: inputs.failOnSubmoduleDiffError
|
failOnSubmoduleDiffError: inputs.failOnSubmoduleDiffError
|
||||||
})
|
})
|
||||||
@ -255,35 +256,11 @@ export async function run(): Promise<void> {
|
|||||||
(!hasGitDirectory || inputs.useRestApi)
|
(!hasGitDirectory || inputs.useRestApi)
|
||||||
) {
|
) {
|
||||||
core.info("Using GitHub's REST API to get changed files")
|
core.info("Using GitHub's REST API to get changed files")
|
||||||
const unsupportedInputs: (keyof Inputs)[] = [
|
if (process.env.GITHUB_ACTION_PATH) {
|
||||||
'sha',
|
await warnUnsupportedRESTAPIInputs({
|
||||||
'baseSha',
|
actionPath: process.env.GITHUB_ACTION_PATH,
|
||||||
'since',
|
inputs
|
||||||
'until',
|
})
|
||||||
'path',
|
|
||||||
'quotePath',
|
|
||||||
'diffRelative',
|
|
||||||
'sinceLastRemoteCommit',
|
|
||||||
'recoverDeletedFiles',
|
|
||||||
'recoverDeletedFilesToDestination',
|
|
||||||
'recoverFiles',
|
|
||||||
'recoverFilesSeparator',
|
|
||||||
'recoverFilesIgnore',
|
|
||||||
'recoverFilesIgnoreSeparator',
|
|
||||||
'includeAllOldNewRenamedFiles',
|
|
||||||
'oldNewSeparator',
|
|
||||||
'oldNewFilesSeparator',
|
|
||||||
'skipInitialFetch',
|
|
||||||
'fetchSubmoduleHistory',
|
|
||||||
'dirNamesDeletedFilesIncludeOnlyDeletedDirs'
|
|
||||||
]
|
|
||||||
|
|
||||||
for (const input of unsupportedInputs) {
|
|
||||||
if (inputs[input]) {
|
|
||||||
core.warning(
|
|
||||||
`Input "${input}" is not supported when using GitHub's REST API to get changed files`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await getChangedFilesFromRESTAPI({
|
await getChangedFilesFromRESTAPI({
|
||||||
inputs,
|
inputs,
|
||||||
|
69
src/utils.ts
69
src/utils.ts
@ -3,14 +3,14 @@ import * as core from '@actions/core'
|
|||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import {createReadStream, promises as fs} from 'fs'
|
import {createReadStream, promises as fs} from 'fs'
|
||||||
import {readFile} from 'fs/promises'
|
import {flattenDeep, snakeCase} from 'lodash'
|
||||||
import {flattenDeep} from 'lodash'
|
|
||||||
import mm from 'micromatch'
|
import mm from 'micromatch'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {createInterface} from 'readline'
|
import {createInterface} from 'readline'
|
||||||
import {parseDocument} from 'yaml'
|
import {parseDocument} from 'yaml'
|
||||||
import {ChangedFiles, ChangeTypeEnum} from './changedFiles'
|
import {ChangedFiles, ChangeTypeEnum} from './changedFiles'
|
||||||
import {DiffResult} from './commitSha'
|
import {DiffResult} from './commitSha'
|
||||||
|
import {UNSUPPORTED_REST_API_INPUTS} from './constant'
|
||||||
import {Inputs} from './inputs'
|
import {Inputs} from './inputs'
|
||||||
|
|
||||||
const MINIMUM_GIT_VERSION = '2.18.0'
|
const MINIMUM_GIT_VERSION = '2.18.0'
|
||||||
@ -285,6 +285,7 @@ export const submoduleExists = async ({
|
|||||||
* Fetches the git repository
|
* Fetches the git repository
|
||||||
* @param args - arguments for fetch command
|
* @param args - arguments for fetch command
|
||||||
* @param cwd - working directory
|
* @param cwd - working directory
|
||||||
|
* @returns exit code
|
||||||
*/
|
*/
|
||||||
export const gitFetch = async ({
|
export const gitFetch = async ({
|
||||||
args,
|
args,
|
||||||
@ -333,6 +334,7 @@ export const gitFetchSubmodules = async ({
|
|||||||
/**
|
/**
|
||||||
* Retrieves all the submodule paths
|
* Retrieves all the submodule paths
|
||||||
* @param cwd - working directory
|
* @param cwd - working directory
|
||||||
|
* @returns submodule paths
|
||||||
*/
|
*/
|
||||||
export const getSubmodulePath = async ({
|
export const getSubmodulePath = async ({
|
||||||
cwd
|
cwd
|
||||||
@ -367,6 +369,7 @@ export const getSubmodulePath = async ({
|
|||||||
* @param parentSha2 - parent commit sha
|
* @param parentSha2 - parent commit sha
|
||||||
* @param submodulePath - path of submodule
|
* @param submodulePath - path of submodule
|
||||||
* @param diff - diff type between parent commits (`..` or `...`)
|
* @param diff - diff type between parent commits (`..` or `...`)
|
||||||
|
* @returns commit sha of submodule
|
||||||
*/
|
*/
|
||||||
export const gitSubmoduleDiffSHA = async ({
|
export const gitSubmoduleDiffSHA = async ({
|
||||||
cwd,
|
cwd,
|
||||||
@ -1128,7 +1131,7 @@ const getYamlFilePatternsFromContents = async ({
|
|||||||
throw new Error(`File does not exist: ${filePath}`)
|
throw new Error(`File does not exist: ${filePath}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
source = await readFile(filePath, 'utf8')
|
source = await fs.readFile(filePath, 'utf8')
|
||||||
} else {
|
} else {
|
||||||
source = content
|
source = content
|
||||||
}
|
}
|
||||||
@ -1491,6 +1494,12 @@ export const recoverDeletedFiles = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the specified working directory has a local Git directory.
|
||||||
|
*
|
||||||
|
* @param workingDirectory - The path of the working directory.
|
||||||
|
* @returns A boolean value indicating whether the working directory has a local Git directory.
|
||||||
|
*/
|
||||||
export const hasLocalGitDirectory = async ({
|
export const hasLocalGitDirectory = async ({
|
||||||
workingDirectory
|
workingDirectory
|
||||||
}: {
|
}: {
|
||||||
@ -1500,3 +1509,57 @@ export const hasLocalGitDirectory = async ({
|
|||||||
cwd: workingDirectory
|
cwd: workingDirectory
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warns about unsupported inputs when using the REST API.
|
||||||
|
*
|
||||||
|
* @param actionPath - The path to the action file.
|
||||||
|
* @param inputs - The inputs object.
|
||||||
|
*/
|
||||||
|
export const warnUnsupportedRESTAPIInputs = async ({
|
||||||
|
actionPath,
|
||||||
|
inputs
|
||||||
|
}: {
|
||||||
|
actionPath: string
|
||||||
|
inputs: Inputs
|
||||||
|
}): Promise<void> => {
|
||||||
|
const actionContents = await fs.readFile(actionPath, 'utf8')
|
||||||
|
const actionYaml = parseDocument(actionContents, {schema: 'failsafe'})
|
||||||
|
|
||||||
|
if (actionYaml.errors.length > 0) {
|
||||||
|
throw new Error(
|
||||||
|
`YAML errors in ${actionPath}: ${actionYaml.errors.join(', ')}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actionYaml.warnings.length > 0) {
|
||||||
|
throw new Error(
|
||||||
|
`YAML warnings in ${actionPath}: ${actionYaml.warnings.join(', ')}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const action = actionYaml.toJS() as {
|
||||||
|
inputs: {
|
||||||
|
[key: string]: {description: string; required: boolean; default: string}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionInputs = action.inputs
|
||||||
|
|
||||||
|
for (const key of UNSUPPORTED_REST_API_INPUTS) {
|
||||||
|
const inputKey = snakeCase(key) as keyof Inputs
|
||||||
|
|
||||||
|
const defaultValue = Object.hasOwnProperty.call(
|
||||||
|
actionInputs[inputKey],
|
||||||
|
'default'
|
||||||
|
)
|
||||||
|
? actionInputs[inputKey].default.toString()
|
||||||
|
: ''
|
||||||
|
|
||||||
|
if (defaultValue !== inputs[key]?.toString()) {
|
||||||
|
core.warning(
|
||||||
|
`Input "${inputKey}" is not supported when using GitHub's REST API to get changed files`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user