feat: switch to use name status (#1230)
Co-authored-by: tj-actions[bot] <109116665+tj-actions-bot@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
2d0b52f440
commit
174a2a6360
@ -60,6 +60,8 @@
|
|||||||
"@typescript-eslint/promise-function-async": "error",
|
"@typescript-eslint/promise-function-async": "error",
|
||||||
"@typescript-eslint/require-array-sort-compare": "error",
|
"@typescript-eslint/require-array-sort-compare": "error",
|
||||||
"@typescript-eslint/restrict-plus-operands": "error",
|
"@typescript-eslint/restrict-plus-operands": "error",
|
||||||
|
"no-shadow": "off",
|
||||||
|
"@typescript-eslint/no-shadow": "error",
|
||||||
"semi": "off",
|
"semi": "off",
|
||||||
"filenames/match-regex": [
|
"filenames/match-regex": [
|
||||||
"error",
|
"error",
|
||||||
|
754
dist/index.js
generated
vendored
754
dist/index.js
generated
vendored
@ -38,10 +38,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getDiffFiles = exports.getRenamedFiles = void 0;
|
exports.getAllChangeTypeFiles = exports.getChangeTypeFiles = exports.getAllDiffFiles = exports.ChangeTypeEnum = exports.getRenamedFiles = void 0;
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const utils_1 = __nccwpck_require__(918);
|
const utils_1 = __nccwpck_require__(918);
|
||||||
|
const flatten_1 = __importDefault(__nccwpck_require__(2394));
|
||||||
const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, submodulePaths }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, submodulePaths }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const renamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
const renamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
@ -80,14 +84,23 @@ const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, s
|
|||||||
return renamedFiles.join(inputs.oldNewFilesSeparator);
|
return renamedFiles.join(inputs.oldNewFilesSeparator);
|
||||||
});
|
});
|
||||||
exports.getRenamedFiles = getRenamedFiles;
|
exports.getRenamedFiles = getRenamedFiles;
|
||||||
const getDiffFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, diffFilter, filePatterns = [], submodulePaths }) => __awaiter(void 0, void 0, void 0, function* () {
|
var ChangeTypeEnum;
|
||||||
let files = yield (0, utils_1.gitDiff)({
|
(function (ChangeTypeEnum) {
|
||||||
|
ChangeTypeEnum["Added"] = "A";
|
||||||
|
ChangeTypeEnum["Copied"] = "C";
|
||||||
|
ChangeTypeEnum["Deleted"] = "D";
|
||||||
|
ChangeTypeEnum["Modified"] = "M";
|
||||||
|
ChangeTypeEnum["Renamed"] = "R";
|
||||||
|
ChangeTypeEnum["TypeChanged"] = "T";
|
||||||
|
ChangeTypeEnum["Unmerged"] = "U";
|
||||||
|
ChangeTypeEnum["Unknown"] = "X";
|
||||||
|
})(ChangeTypeEnum || (exports.ChangeTypeEnum = ChangeTypeEnum = {}));
|
||||||
|
const getAllDiffFiles = ({ workingDirectory, hasSubmodule, diffResult, submodulePaths }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const files = yield (0, utils_1.getAllChangedFiles)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
sha1: diffResult.previousSha,
|
sha1: diffResult.previousSha,
|
||||||
sha2: diffResult.currentSha,
|
sha2: diffResult.currentSha,
|
||||||
diff: diffResult.diff,
|
diff: diffResult.diff
|
||||||
diffFilter,
|
|
||||||
filePatterns
|
|
||||||
});
|
});
|
||||||
if (hasSubmodule) {
|
if (hasSubmodule) {
|
||||||
for (const submodulePath of submodulePaths) {
|
for (const submodulePath of submodulePaths) {
|
||||||
@ -100,34 +113,77 @@ const getDiffFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, diff
|
|||||||
});
|
});
|
||||||
const submoduleWorkingDirectory = path.join(workingDirectory, submodulePath);
|
const submoduleWorkingDirectory = path.join(workingDirectory, submodulePath);
|
||||||
if (submoduleShaResult.currentSha && submoduleShaResult.previousSha) {
|
if (submoduleShaResult.currentSha && submoduleShaResult.previousSha) {
|
||||||
const submoduleFiles = yield (0, utils_1.gitDiff)({
|
const submoduleFiles = yield (0, utils_1.getAllChangedFiles)({
|
||||||
cwd: submoduleWorkingDirectory,
|
cwd: submoduleWorkingDirectory,
|
||||||
sha1: submoduleShaResult.previousSha,
|
sha1: submoduleShaResult.previousSha,
|
||||||
sha2: submoduleShaResult.currentSha,
|
sha2: submoduleShaResult.currentSha,
|
||||||
diff: diffResult.diff,
|
diff: diffResult.diff,
|
||||||
diffFilter,
|
|
||||||
isSubmodule: true,
|
isSubmodule: true,
|
||||||
filePatterns,
|
|
||||||
parentDir: submodulePath
|
parentDir: submodulePath
|
||||||
});
|
});
|
||||||
files.push(...submoduleFiles);
|
for (const changeType of Object.keys(submoduleFiles)) {
|
||||||
|
if (!files[changeType]) {
|
||||||
|
files[changeType] = [];
|
||||||
|
}
|
||||||
|
files[changeType].push(...submoduleFiles[changeType]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
});
|
||||||
|
exports.getAllDiffFiles = getAllDiffFiles;
|
||||||
|
function* getChangeTypeFilesGenerator({ inputs, changedFiles, changeTypes }) {
|
||||||
|
for (const changeType of changeTypes) {
|
||||||
|
const files = changedFiles[changeType] || [];
|
||||||
|
for (const file of files) {
|
||||||
if (inputs.dirNames) {
|
if (inputs.dirNames) {
|
||||||
files = files.map(file => (0, utils_1.getDirnameMaxDepth)({
|
yield (0, utils_1.getDirnameMaxDepth)({
|
||||||
pathStr: file,
|
pathStr: file,
|
||||||
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
||||||
excludeCurrentDir: inputs.dirNamesExcludeRoot || inputs.dirNamesExcludeCurrentDir
|
excludeCurrentDir: inputs.dirNamesExcludeRoot || inputs.dirNamesExcludeCurrentDir
|
||||||
}));
|
});
|
||||||
files = [...new Set(files)];
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
yield file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const getChangeTypeFiles = ({ inputs, changedFiles, changeTypes }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const files = [
|
||||||
|
...new Set(getChangeTypeFilesGenerator({ inputs, changedFiles, changeTypes }))
|
||||||
|
];
|
||||||
if (inputs.json) {
|
if (inputs.json) {
|
||||||
return (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson });
|
return (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson });
|
||||||
}
|
}
|
||||||
return files.join(inputs.separator);
|
return files.join(inputs.separator);
|
||||||
});
|
});
|
||||||
exports.getDiffFiles = getDiffFiles;
|
exports.getChangeTypeFiles = getChangeTypeFiles;
|
||||||
|
function* getAllChangeTypeFilesGenerator({ inputs, changedFiles }) {
|
||||||
|
for (const file of (0, flatten_1.default)(Object.values(changedFiles))) {
|
||||||
|
if (inputs.dirNames) {
|
||||||
|
yield (0, utils_1.getDirnameMaxDepth)({
|
||||||
|
pathStr: file,
|
||||||
|
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
||||||
|
excludeCurrentDir: inputs.dirNamesExcludeRoot || inputs.dirNamesExcludeCurrentDir
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
yield file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const getAllChangeTypeFiles = ({ inputs, changedFiles }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const files = [
|
||||||
|
...new Set(getAllChangeTypeFilesGenerator({ inputs, changedFiles }))
|
||||||
|
];
|
||||||
|
if (inputs.json) {
|
||||||
|
return (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson });
|
||||||
|
}
|
||||||
|
return files.join(inputs.separator);
|
||||||
|
});
|
||||||
|
exports.getAllChangeTypeFiles = getAllChangeTypeFiles;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -444,8 +500,17 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
}
|
}
|
||||||
if (!previousSha) {
|
if (!previousSha) {
|
||||||
if (inputs.sinceLastRemoteCommit) {
|
if (inputs.sinceLastRemoteCommit) {
|
||||||
previousSha = env.GITHUB_EVENT_BEFORE;
|
previousSha =
|
||||||
if ((yield (0, utils_1.verifyCommitSha)({ sha: previousSha, cwd: workingDirectory })) !== 0) {
|
env.GITHUB_EVENT_BEFORE ||
|
||||||
|
(yield (0, utils_1.getRemoteBranchHeadSha)({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
branch: currentBranch
|
||||||
|
}));
|
||||||
|
if (!previousSha ||
|
||||||
|
(previousSha &&
|
||||||
|
(yield (0, utils_1.verifyCommitSha)({ sha: previousSha, cwd: workingDirectory })) !==
|
||||||
|
0)) {
|
||||||
|
core.warning('Unable to locate the remote branch head sha. Falling back to the pull request base sha.');
|
||||||
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA;
|
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -856,29 +921,34 @@ function run() {
|
|||||||
inputs,
|
inputs,
|
||||||
workingDirectory
|
workingDirectory
|
||||||
});
|
});
|
||||||
const addedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
core.debug(`File patterns: ${filePatterns}`);
|
||||||
inputs,
|
const allDiffFiles = yield (0, changedFiles_1.getAllDiffFiles)({
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
diffFilter: 'A',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
submodulePaths
|
||||||
});
|
});
|
||||||
|
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`);
|
||||||
|
const allFilteredDiffFiles = yield (0, utils_1.getFilteredChangedFiles)({
|
||||||
|
allDiffFiles,
|
||||||
|
filePatterns
|
||||||
|
});
|
||||||
|
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`);
|
||||||
|
const addedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
|
inputs,
|
||||||
|
changedFiles: allFilteredDiffFiles,
|
||||||
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Added]
|
||||||
|
});
|
||||||
core.debug(`Added files: ${addedFiles}`);
|
core.debug(`Added files: ${addedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: 'added_files',
|
key: 'added_files',
|
||||||
value: addedFiles,
|
value: addedFiles,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const copiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const copiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Copied]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'C',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
});
|
});
|
||||||
core.debug(`Copied files: ${copiedFiles}`);
|
core.debug(`Copied files: ${copiedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -886,14 +956,10 @@ function run() {
|
|||||||
value: copiedFiles,
|
value: copiedFiles,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const modifiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const modifiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Modified]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'M',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
});
|
});
|
||||||
core.debug(`Modified files: ${modifiedFiles}`);
|
core.debug(`Modified files: ${modifiedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -901,14 +967,10 @@ function run() {
|
|||||||
value: modifiedFiles,
|
value: modifiedFiles,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const renamedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const renamedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Renamed]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'R',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
});
|
});
|
||||||
core.debug(`Renamed files: ${renamedFiles}`);
|
core.debug(`Renamed files: ${renamedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -916,14 +978,10 @@ function run() {
|
|||||||
value: renamedFiles,
|
value: renamedFiles,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const typeChangedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const typeChangedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [changedFiles_1.ChangeTypeEnum.TypeChanged]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'T',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
});
|
});
|
||||||
core.debug(`Type changed files: ${typeChangedFiles}`);
|
core.debug(`Type changed files: ${typeChangedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -931,14 +989,10 @@ function run() {
|
|||||||
value: typeChangedFiles,
|
value: typeChangedFiles,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const unmergedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const unmergedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Unmerged]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'U',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
});
|
});
|
||||||
core.debug(`Unmerged files: ${unmergedFiles}`);
|
core.debug(`Unmerged files: ${unmergedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -946,14 +1000,10 @@ function run() {
|
|||||||
value: unmergedFiles,
|
value: unmergedFiles,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const unknownFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const unknownFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Unknown]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'X',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
});
|
});
|
||||||
core.debug(`Unknown files: ${unknownFiles}`);
|
core.debug(`Unknown files: ${unknownFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -961,14 +1011,9 @@ function run() {
|
|||||||
value: unknownFiles,
|
value: unknownFiles,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const allChangedAndModifiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const allChangedAndModifiedFiles = yield (0, changedFiles_1.getAllChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles
|
||||||
hasSubmodule,
|
|
||||||
diffResult,
|
|
||||||
diffFilter: 'ACDMRTUX',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
});
|
});
|
||||||
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`);
|
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -976,14 +1021,15 @@ function run() {
|
|||||||
value: allChangedAndModifiedFiles,
|
value: allChangedAndModifiedFiles,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const allChangedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const allChangedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
changedFiles_1.ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMR',
|
changedFiles_1.ChangeTypeEnum.Copied,
|
||||||
filePatterns,
|
changedFiles_1.ChangeTypeEnum.Modified,
|
||||||
submodulePaths
|
changedFiles_1.ChangeTypeEnum.Renamed
|
||||||
|
]
|
||||||
});
|
});
|
||||||
core.debug(`All changed files: ${allChangedFiles}`);
|
core.debug(`All changed files: ${allChangedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -996,13 +1042,15 @@ function run() {
|
|||||||
value: allChangedFiles.length > 0 && filePatterns.length > 0,
|
value: allChangedFiles.length > 0 && filePatterns.length > 0,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const allOtherChangedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const allOtherChangedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
changedFiles_1.ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMR',
|
changedFiles_1.ChangeTypeEnum.Copied,
|
||||||
submodulePaths
|
changedFiles_1.ChangeTypeEnum.Modified,
|
||||||
|
changedFiles_1.ChangeTypeEnum.Renamed
|
||||||
|
]
|
||||||
});
|
});
|
||||||
core.debug(`All other changed files: ${allOtherChangedFiles}`);
|
core.debug(`All other changed files: ${allOtherChangedFiles}`);
|
||||||
const otherChangedFiles = allOtherChangedFiles
|
const otherChangedFiles = allOtherChangedFiles
|
||||||
@ -1021,14 +1069,16 @@ function run() {
|
|||||||
value: otherChangedFiles.join(inputs.separator),
|
value: otherChangedFiles.join(inputs.separator),
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const allModifiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const allModifiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
changedFiles_1.ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMRD',
|
changedFiles_1.ChangeTypeEnum.Copied,
|
||||||
filePatterns,
|
changedFiles_1.ChangeTypeEnum.Modified,
|
||||||
submodulePaths
|
changedFiles_1.ChangeTypeEnum.Renamed,
|
||||||
|
changedFiles_1.ChangeTypeEnum.Deleted
|
||||||
|
]
|
||||||
});
|
});
|
||||||
core.debug(`All modified files: ${allModifiedFiles}`);
|
core.debug(`All modified files: ${allModifiedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -1041,13 +1091,16 @@ function run() {
|
|||||||
value: allModifiedFiles.length > 0 && filePatterns.length > 0,
|
value: allModifiedFiles.length > 0 && filePatterns.length > 0,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const allOtherModifiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const allOtherModifiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
changedFiles_1.ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMRD',
|
changedFiles_1.ChangeTypeEnum.Copied,
|
||||||
submodulePaths
|
changedFiles_1.ChangeTypeEnum.Modified,
|
||||||
|
changedFiles_1.ChangeTypeEnum.Renamed,
|
||||||
|
changedFiles_1.ChangeTypeEnum.Deleted
|
||||||
|
]
|
||||||
});
|
});
|
||||||
const otherModifiedFiles = allOtherModifiedFiles
|
const otherModifiedFiles = allOtherModifiedFiles
|
||||||
.split(inputs.separator)
|
.split(inputs.separator)
|
||||||
@ -1065,14 +1118,10 @@ function run() {
|
|||||||
value: otherModifiedFiles.join(inputs.separator),
|
value: otherModifiedFiles.join(inputs.separator),
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const deletedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const deletedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Deleted]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'D',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
});
|
});
|
||||||
core.debug(`Deleted files: ${deletedFiles}`);
|
core.debug(`Deleted files: ${deletedFiles}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
@ -1085,13 +1134,10 @@ function run() {
|
|||||||
value: deletedFiles.length > 0 && filePatterns.length > 0,
|
value: deletedFiles.length > 0 && filePatterns.length > 0,
|
||||||
inputs
|
inputs
|
||||||
});
|
});
|
||||||
const allOtherDeletedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
const allOtherDeletedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Deleted]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'D',
|
|
||||||
submodulePaths
|
|
||||||
});
|
});
|
||||||
const otherDeletedFiles = allOtherDeletedFiles
|
const otherDeletedFiles = allOtherDeletedFiles
|
||||||
.split(inputs.separator)
|
.split(inputs.separator)
|
||||||
@ -1200,7 +1246,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.setOutput = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.getHeadSha = exports.gitLog = exports.gitDiff = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
|
exports.setOutput = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = 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.verifyMinimumGitVersion = 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));
|
||||||
@ -1208,6 +1254,7 @@ const fs_1 = __nccwpck_require__(7147);
|
|||||||
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 changedFiles_1 = __nccwpck_require__(7358);
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
const MINIMUM_GIT_VERSION = '2.18.0';
|
const MINIMUM_GIT_VERSION = '2.18.0';
|
||||||
/**
|
/**
|
||||||
@ -1483,18 +1530,28 @@ const gitRenamedFiles = ({ cwd, sha1, sha2, diff, oldNewSeparator, isSubmodule =
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
exports.gitRenamedFiles = gitRenamedFiles;
|
exports.gitRenamedFiles = gitRenamedFiles;
|
||||||
const gitDiff = ({ cwd, sha1, sha2, diff, diffFilter, filePatterns = [], isSubmodule = false, parentDir = '' }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getAllChangedFiles = ({ cwd, sha1, sha2, diff, isSubmodule = false, parentDir = '' }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', [
|
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', [
|
||||||
'diff',
|
'diff',
|
||||||
'--name-only',
|
'--name-status',
|
||||||
'--ignore-submodules=all',
|
'--ignore-submodules=all',
|
||||||
`--diff-filter=${diffFilter}`,
|
`--diff-filter=ACDMRTUX`,
|
||||||
`${sha1}${diff}${sha2}`
|
`${sha1}${diff}${sha2}`
|
||||||
], {
|
], {
|
||||||
cwd,
|
cwd,
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: process.env.RUNNER_DEBUG !== '1'
|
silent: process.env.RUNNER_DEBUG !== '1'
|
||||||
});
|
});
|
||||||
|
const changedFiles = {
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Added]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Copied]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Deleted]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Modified]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Renamed]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.TypeChanged]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Unmerged]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Unknown]: []
|
||||||
|
};
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
if (isSubmodule) {
|
if (isSubmodule) {
|
||||||
core.warning(stderr ||
|
core.warning(stderr ||
|
||||||
@ -1504,27 +1561,52 @@ const gitDiff = ({ cwd, sha1, sha2, diff, diffFilter, filePatterns = [], isSubmo
|
|||||||
else {
|
else {
|
||||||
core.warning(stderr || `Failed to get changed files between: ${sha1}${diff}${sha2}`);
|
core.warning(stderr || `Failed to get changed files between: ${sha1}${diff}${sha2}`);
|
||||||
}
|
}
|
||||||
return [];
|
return changedFiles;
|
||||||
}
|
}
|
||||||
const files = stdout
|
const lines = stdout.split('\n').filter(Boolean);
|
||||||
.split('\n')
|
for (const line of lines) {
|
||||||
.filter(Boolean)
|
const [changeType, filePath] = line.split('\t');
|
||||||
.map((p) => {
|
const normalizedFilePath = isSubmodule
|
||||||
if (isSubmodule) {
|
? normalizePath(path.join(parentDir, filePath))
|
||||||
return normalizePath(path.join(parentDir, p));
|
: normalizePath(filePath);
|
||||||
|
if (changeType.startsWith('R')) {
|
||||||
|
changedFiles[changedFiles_1.ChangeTypeEnum.Renamed].push(normalizedFilePath);
|
||||||
}
|
}
|
||||||
return normalizePath(p);
|
else {
|
||||||
});
|
changedFiles[changeType].push(normalizedFilePath);
|
||||||
if (filePatterns.length === 0) {
|
|
||||||
return files;
|
|
||||||
}
|
}
|
||||||
return (0, micromatch_1.default)(files, filePatterns, {
|
}
|
||||||
|
return changedFiles;
|
||||||
|
});
|
||||||
|
exports.getAllChangedFiles = getAllChangedFiles;
|
||||||
|
const getFilteredChangedFiles = ({ allDiffFiles, filePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const changedFiles = {
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Added]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Copied]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Deleted]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Modified]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Renamed]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.TypeChanged]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Unmerged]: [],
|
||||||
|
[changedFiles_1.ChangeTypeEnum.Unknown]: []
|
||||||
|
};
|
||||||
|
for (const changeType of Object.keys(allDiffFiles)) {
|
||||||
|
const files = allDiffFiles[changeType];
|
||||||
|
const hasFilePatterns = filePatterns.length > 0;
|
||||||
|
if (hasFilePatterns) {
|
||||||
|
changedFiles[changeType] = (0, micromatch_1.default)(files, filePatterns, {
|
||||||
dot: true,
|
dot: true,
|
||||||
windows: IS_WINDOWS,
|
windows: IS_WINDOWS,
|
||||||
noext: true
|
noext: true
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
changedFiles[changeType] = files;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changedFiles;
|
||||||
});
|
});
|
||||||
exports.gitDiff = gitDiff;
|
exports.getFilteredChangedFiles = getFilteredChangedFiles;
|
||||||
const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const { stdout } = yield exec.getExecOutput('git', ['log', ...args], {
|
const { stdout } = yield exec.getExecOutput('git', ['log', ...args], {
|
||||||
cwd,
|
cwd,
|
||||||
@ -5935,6 +6017,428 @@ module.exports = function(num) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 9213:
|
||||||
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
var root = __nccwpck_require__(9882);
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var Symbol = root.Symbol;
|
||||||
|
|
||||||
|
module.exports = Symbol;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 82:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the elements of `values` to `array`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to modify.
|
||||||
|
* @param {Array} values The values to append.
|
||||||
|
* @returns {Array} Returns `array`.
|
||||||
|
*/
|
||||||
|
function arrayPush(array, values) {
|
||||||
|
var index = -1,
|
||||||
|
length = values.length,
|
||||||
|
offset = array.length;
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
array[offset + index] = values[index];
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = arrayPush;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 9588:
|
||||||
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
var arrayPush = __nccwpck_require__(82),
|
||||||
|
isFlattenable = __nccwpck_require__(9299);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.flatten` with support for restricting flattening.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to flatten.
|
||||||
|
* @param {number} depth The maximum recursion depth.
|
||||||
|
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
||||||
|
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
||||||
|
* @param {Array} [result=[]] The initial result value.
|
||||||
|
* @returns {Array} Returns the new flattened array.
|
||||||
|
*/
|
||||||
|
function baseFlatten(array, depth, predicate, isStrict, result) {
|
||||||
|
var index = -1,
|
||||||
|
length = array.length;
|
||||||
|
|
||||||
|
predicate || (predicate = isFlattenable);
|
||||||
|
result || (result = []);
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
var value = array[index];
|
||||||
|
if (depth > 0 && predicate(value)) {
|
||||||
|
if (depth > 1) {
|
||||||
|
// Recursively flatten arrays (susceptible to call stack limits).
|
||||||
|
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
||||||
|
} else {
|
||||||
|
arrayPush(result, value);
|
||||||
|
}
|
||||||
|
} else if (!isStrict) {
|
||||||
|
result[result.length] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseFlatten;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 7497:
|
||||||
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
var Symbol = __nccwpck_require__(9213),
|
||||||
|
getRawTag = __nccwpck_require__(923),
|
||||||
|
objectToString = __nccwpck_require__(4200);
|
||||||
|
|
||||||
|
/** `Object#toString` result references. */
|
||||||
|
var nullTag = '[object Null]',
|
||||||
|
undefinedTag = '[object Undefined]';
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `getTag` without fallbacks for buggy environments.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to query.
|
||||||
|
* @returns {string} Returns the `toStringTag`.
|
||||||
|
*/
|
||||||
|
function baseGetTag(value) {
|
||||||
|
if (value == null) {
|
||||||
|
return value === undefined ? undefinedTag : nullTag;
|
||||||
|
}
|
||||||
|
return (symToStringTag && symToStringTag in Object(value))
|
||||||
|
? getRawTag(value)
|
||||||
|
: objectToString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseGetTag;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2177:
|
||||||
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
var baseGetTag = __nccwpck_require__(7497),
|
||||||
|
isObjectLike = __nccwpck_require__(5926);
|
||||||
|
|
||||||
|
/** `Object#toString` result references. */
|
||||||
|
var argsTag = '[object Arguments]';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.isArguments`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||||||
|
*/
|
||||||
|
function baseIsArguments(value) {
|
||||||
|
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseIsArguments;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2085:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
/** Detect free variable `global` from Node.js. */
|
||||||
|
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
||||||
|
|
||||||
|
module.exports = freeGlobal;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 923:
|
||||||
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
var Symbol = __nccwpck_require__(9213);
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
|
/** Used to check objects for own properties. */
|
||||||
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to resolve the
|
||||||
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||||
|
* of values.
|
||||||
|
*/
|
||||||
|
var nativeObjectToString = objectProto.toString;
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to query.
|
||||||
|
* @returns {string} Returns the raw `toStringTag`.
|
||||||
|
*/
|
||||||
|
function getRawTag(value) {
|
||||||
|
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
||||||
|
tag = value[symToStringTag];
|
||||||
|
|
||||||
|
try {
|
||||||
|
value[symToStringTag] = undefined;
|
||||||
|
var unmasked = true;
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
var result = nativeObjectToString.call(value);
|
||||||
|
if (unmasked) {
|
||||||
|
if (isOwn) {
|
||||||
|
value[symToStringTag] = tag;
|
||||||
|
} else {
|
||||||
|
delete value[symToStringTag];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getRawTag;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 9299:
|
||||||
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
var Symbol = __nccwpck_require__(9213),
|
||||||
|
isArguments = __nccwpck_require__(8495),
|
||||||
|
isArray = __nccwpck_require__(4869);
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if `value` is a flattenable `arguments` object or array.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
||||||
|
*/
|
||||||
|
function isFlattenable(value) {
|
||||||
|
return isArray(value) || isArguments(value) ||
|
||||||
|
!!(spreadableSymbol && value && value[spreadableSymbol]);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = isFlattenable;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 4200:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to resolve the
|
||||||
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||||
|
* of values.
|
||||||
|
*/
|
||||||
|
var nativeObjectToString = objectProto.toString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts `value` to a string using `Object.prototype.toString`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to convert.
|
||||||
|
* @returns {string} Returns the converted string.
|
||||||
|
*/
|
||||||
|
function objectToString(value) {
|
||||||
|
return nativeObjectToString.call(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = objectToString;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 9882:
|
||||||
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
var freeGlobal = __nccwpck_require__(2085);
|
||||||
|
|
||||||
|
/** Detect free variable `self`. */
|
||||||
|
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
||||||
|
|
||||||
|
/** Used as a reference to the global object. */
|
||||||
|
var root = freeGlobal || freeSelf || Function('return this')();
|
||||||
|
|
||||||
|
module.exports = root;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2394:
|
||||||
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
var baseFlatten = __nccwpck_require__(9588);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flattens `array` a single level deep.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @since 0.1.0
|
||||||
|
* @category Array
|
||||||
|
* @param {Array} array The array to flatten.
|
||||||
|
* @returns {Array} Returns the new flattened array.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* _.flatten([1, [2, [3, [4]], 5]]);
|
||||||
|
* // => [1, 2, [3, [4]], 5]
|
||||||
|
*/
|
||||||
|
function flatten(array) {
|
||||||
|
var length = array == null ? 0 : array.length;
|
||||||
|
return length ? baseFlatten(array, 1) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = flatten;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 8495:
|
||||||
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
var baseIsArguments = __nccwpck_require__(2177),
|
||||||
|
isObjectLike = __nccwpck_require__(5926);
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
|
/** Used to check objects for own properties. */
|
||||||
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if `value` is likely an `arguments` object.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @since 0.1.0
|
||||||
|
* @category Lang
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||||||
|
* else `false`.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* _.isArguments(function() { return arguments; }());
|
||||||
|
* // => true
|
||||||
|
*
|
||||||
|
* _.isArguments([1, 2, 3]);
|
||||||
|
* // => false
|
||||||
|
*/
|
||||||
|
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
||||||
|
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
||||||
|
!propertyIsEnumerable.call(value, 'callee');
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = isArguments;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 4869:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if `value` is classified as an `Array` object.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @since 0.1.0
|
||||||
|
* @category Lang
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* _.isArray([1, 2, 3]);
|
||||||
|
* // => true
|
||||||
|
*
|
||||||
|
* _.isArray(document.body.children);
|
||||||
|
* // => false
|
||||||
|
*
|
||||||
|
* _.isArray('abc');
|
||||||
|
* // => false
|
||||||
|
*
|
||||||
|
* _.isArray(_.noop);
|
||||||
|
* // => false
|
||||||
|
*/
|
||||||
|
var isArray = Array.isArray;
|
||||||
|
|
||||||
|
module.exports = isArray;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 5926:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
||||||
|
* and has a `typeof` result of "object".
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @since 4.0.0
|
||||||
|
* @category Lang
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* _.isObjectLike({});
|
||||||
|
* // => true
|
||||||
|
*
|
||||||
|
* _.isObjectLike([1, 2, 3]);
|
||||||
|
* // => true
|
||||||
|
*
|
||||||
|
* _.isObjectLike(_.noop);
|
||||||
|
* // => false
|
||||||
|
*
|
||||||
|
* _.isObjectLike(null);
|
||||||
|
* // => false
|
||||||
|
*/
|
||||||
|
function isObjectLike(value) {
|
||||||
|
return value != null && typeof value == 'object';
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = isObjectLike;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6228:
|
/***/ 6228:
|
||||||
|
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
51
dist/licenses.txt
generated
vendored
51
dist/licenses.txt
generated
vendored
@ -134,6 +134,57 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
lodash
|
||||||
|
MIT
|
||||||
|
Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||||
|
|
||||||
|
Based on Underscore.js, copyright Jeremy Ashkenas,
|
||||||
|
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||||
|
|
||||||
|
This software consists of voluntary contributions made by many
|
||||||
|
individuals. For exact contribution history, see the revision history
|
||||||
|
available at https://github.com/lodash/lodash
|
||||||
|
|
||||||
|
The following license applies to all parts of this software except as
|
||||||
|
documented below:
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Copyright and related rights for sample code are waived via CC0. Sample
|
||||||
|
code is defined as all source code displayed within the prose of the
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
CC0: http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Files located in the node_modules and vendor directories are externally
|
||||||
|
maintained libraries used by this software which have their own
|
||||||
|
licenses; we recommend you read them, as their terms may differ from the
|
||||||
|
terms above.
|
||||||
|
|
||||||
|
|
||||||
micromatch
|
micromatch
|
||||||
MIT
|
MIT
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
@ -34,10 +34,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "1.10.0",
|
"@actions/core": "1.10.0",
|
||||||
"@actions/exec": "1.1.1",
|
"@actions/exec": "1.1.1",
|
||||||
|
"lodash": "^4.17.15",
|
||||||
"micromatch": "^4.0.5"
|
"micromatch": "^4.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "29.5.2",
|
"@types/jest": "29.5.2",
|
||||||
|
"@types/lodash": "^4.14.195",
|
||||||
"@types/micromatch": "^4.0.2",
|
"@types/micromatch": "^4.0.2",
|
||||||
"@types/node": "20.2.1",
|
"@types/node": "20.2.1",
|
||||||
"@types/uuid": "9.0.2",
|
"@types/uuid": "9.0.2",
|
||||||
|
@ -4,11 +4,12 @@ import {DiffResult} from './commitSha'
|
|||||||
import {Inputs} from './inputs'
|
import {Inputs} from './inputs'
|
||||||
import {
|
import {
|
||||||
getDirnameMaxDepth,
|
getDirnameMaxDepth,
|
||||||
gitDiff,
|
|
||||||
gitRenamedFiles,
|
gitRenamedFiles,
|
||||||
gitSubmoduleDiffSHA,
|
gitSubmoduleDiffSHA,
|
||||||
jsonOutput
|
jsonOutput,
|
||||||
|
getAllChangedFiles
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
import flatten from 'lodash/flatten'
|
||||||
|
|
||||||
export const getRenamedFiles = async ({
|
export const getRenamedFiles = async ({
|
||||||
inputs,
|
inputs,
|
||||||
@ -68,30 +69,37 @@ export const getRenamedFiles = async ({
|
|||||||
return renamedFiles.join(inputs.oldNewFilesSeparator)
|
return renamedFiles.join(inputs.oldNewFilesSeparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getDiffFiles = async ({
|
export enum ChangeTypeEnum {
|
||||||
inputs,
|
Added = 'A',
|
||||||
|
Copied = 'C',
|
||||||
|
Deleted = 'D',
|
||||||
|
Modified = 'M',
|
||||||
|
Renamed = 'R',
|
||||||
|
TypeChanged = 'T',
|
||||||
|
Unmerged = 'U',
|
||||||
|
Unknown = 'X'
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ChangedFiles = {
|
||||||
|
[key in ChangeTypeEnum]: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getAllDiffFiles = async ({
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
diffFilter,
|
|
||||||
filePatterns = [],
|
|
||||||
submodulePaths
|
submodulePaths
|
||||||
}: {
|
}: {
|
||||||
inputs: Inputs
|
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
hasSubmodule: boolean
|
hasSubmodule: boolean
|
||||||
diffResult: DiffResult
|
diffResult: DiffResult
|
||||||
diffFilter: string
|
|
||||||
filePatterns?: string[]
|
|
||||||
submodulePaths: string[]
|
submodulePaths: string[]
|
||||||
}): Promise<string> => {
|
}): Promise<ChangedFiles> => {
|
||||||
let files = await gitDiff({
|
const files = await getAllChangedFiles({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
sha1: diffResult.previousSha,
|
sha1: diffResult.previousSha,
|
||||||
sha2: diffResult.currentSha,
|
sha2: diffResult.currentSha,
|
||||||
diff: diffResult.diff,
|
diff: diffResult.diff
|
||||||
diffFilter,
|
|
||||||
filePatterns
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (hasSubmodule) {
|
||||||
@ -110,32 +118,107 @@ export const getDiffFiles = async ({
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (submoduleShaResult.currentSha && submoduleShaResult.previousSha) {
|
if (submoduleShaResult.currentSha && submoduleShaResult.previousSha) {
|
||||||
const submoduleFiles = await gitDiff({
|
const submoduleFiles = await getAllChangedFiles({
|
||||||
cwd: submoduleWorkingDirectory,
|
cwd: submoduleWorkingDirectory,
|
||||||
sha1: submoduleShaResult.previousSha,
|
sha1: submoduleShaResult.previousSha,
|
||||||
sha2: submoduleShaResult.currentSha,
|
sha2: submoduleShaResult.currentSha,
|
||||||
diff: diffResult.diff,
|
diff: diffResult.diff,
|
||||||
diffFilter,
|
|
||||||
isSubmodule: true,
|
isSubmodule: true,
|
||||||
filePatterns,
|
|
||||||
parentDir: submodulePath
|
parentDir: submodulePath
|
||||||
})
|
})
|
||||||
files.push(...submoduleFiles)
|
|
||||||
|
for (const changeType of Object.keys(
|
||||||
|
submoduleFiles
|
||||||
|
) as ChangeTypeEnum[]) {
|
||||||
|
if (!files[changeType]) {
|
||||||
|
files[changeType] = []
|
||||||
|
}
|
||||||
|
files[changeType].push(...submoduleFiles[changeType])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return files
|
||||||
|
}
|
||||||
|
|
||||||
|
function* getChangeTypeFilesGenerator({
|
||||||
|
inputs,
|
||||||
|
changedFiles,
|
||||||
|
changeTypes
|
||||||
|
}: {
|
||||||
|
inputs: Inputs
|
||||||
|
changedFiles: ChangedFiles
|
||||||
|
changeTypes: ChangeTypeEnum[]
|
||||||
|
}): Generator<string> {
|
||||||
|
for (const changeType of changeTypes) {
|
||||||
|
const files = changedFiles[changeType] || []
|
||||||
|
for (const file of files) {
|
||||||
if (inputs.dirNames) {
|
if (inputs.dirNames) {
|
||||||
files = files.map(file =>
|
yield getDirnameMaxDepth({
|
||||||
getDirnameMaxDepth({
|
|
||||||
pathStr: file,
|
pathStr: file,
|
||||||
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
||||||
excludeCurrentDir:
|
excludeCurrentDir:
|
||||||
inputs.dirNamesExcludeRoot || inputs.dirNamesExcludeCurrentDir
|
inputs.dirNamesExcludeRoot || inputs.dirNamesExcludeCurrentDir
|
||||||
})
|
})
|
||||||
)
|
} else {
|
||||||
files = [...new Set(files)]
|
yield file
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getChangeTypeFiles = async ({
|
||||||
|
inputs,
|
||||||
|
changedFiles,
|
||||||
|
changeTypes
|
||||||
|
}: {
|
||||||
|
inputs: Inputs
|
||||||
|
changedFiles: ChangedFiles
|
||||||
|
changeTypes: ChangeTypeEnum[]
|
||||||
|
}): Promise<string> => {
|
||||||
|
const files = [
|
||||||
|
...new Set(getChangeTypeFilesGenerator({inputs, changedFiles, changeTypes}))
|
||||||
|
]
|
||||||
|
|
||||||
|
if (inputs.json) {
|
||||||
|
return jsonOutput({value: files, shouldEscape: inputs.escapeJson})
|
||||||
|
}
|
||||||
|
|
||||||
|
return files.join(inputs.separator)
|
||||||
|
}
|
||||||
|
|
||||||
|
function* getAllChangeTypeFilesGenerator({
|
||||||
|
inputs,
|
||||||
|
changedFiles
|
||||||
|
}: {
|
||||||
|
inputs: Inputs
|
||||||
|
changedFiles: ChangedFiles
|
||||||
|
}): Generator<string> {
|
||||||
|
for (const file of flatten(Object.values(changedFiles))) {
|
||||||
|
if (inputs.dirNames) {
|
||||||
|
yield getDirnameMaxDepth({
|
||||||
|
pathStr: file,
|
||||||
|
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
||||||
|
excludeCurrentDir:
|
||||||
|
inputs.dirNamesExcludeRoot || inputs.dirNamesExcludeCurrentDir
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
yield file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getAllChangeTypeFiles = async ({
|
||||||
|
inputs,
|
||||||
|
changedFiles
|
||||||
|
}: {
|
||||||
|
inputs: Inputs
|
||||||
|
changedFiles: ChangedFiles
|
||||||
|
}): Promise<string> => {
|
||||||
|
const files = [
|
||||||
|
...new Set(getAllChangeTypeFilesGenerator({inputs, changedFiles}))
|
||||||
|
]
|
||||||
|
|
||||||
if (inputs.json) {
|
if (inputs.json) {
|
||||||
return jsonOutput({value: files, shouldEscape: inputs.escapeJson})
|
return jsonOutput({value: files, shouldEscape: inputs.escapeJson})
|
||||||
|
@ -370,11 +370,22 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
|
|
||||||
if (!previousSha) {
|
if (!previousSha) {
|
||||||
if (inputs.sinceLastRemoteCommit) {
|
if (inputs.sinceLastRemoteCommit) {
|
||||||
previousSha = env.GITHUB_EVENT_BEFORE
|
previousSha =
|
||||||
|
env.GITHUB_EVENT_BEFORE ||
|
||||||
|
(await getRemoteBranchHeadSha({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
branch: currentBranch
|
||||||
|
}))
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(await verifyCommitSha({sha: previousSha, cwd: workingDirectory})) !== 0
|
!previousSha ||
|
||||||
|
(previousSha &&
|
||||||
|
(await verifyCommitSha({sha: previousSha, cwd: workingDirectory})) !==
|
||||||
|
0)
|
||||||
) {
|
) {
|
||||||
|
core.warning(
|
||||||
|
'Unable to locate the remote branch head sha. Falling back to the pull request base sha.'
|
||||||
|
)
|
||||||
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
180
src/main.ts
180
src/main.ts
@ -1,15 +1,22 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import {getDiffFiles, getRenamedFiles} from './changedFiles'
|
|
||||||
import {
|
import {
|
||||||
|
getAllChangeTypeFiles,
|
||||||
|
getAllDiffFiles,
|
||||||
|
getChangeTypeFiles,
|
||||||
|
getRenamedFiles,
|
||||||
|
ChangeTypeEnum
|
||||||
|
} from './changedFiles'
|
||||||
|
import {
|
||||||
|
DiffResult,
|
||||||
getSHAForPullRequestEvent,
|
getSHAForPullRequestEvent,
|
||||||
getSHAForPushEvent,
|
getSHAForPushEvent
|
||||||
DiffResult
|
|
||||||
} from './commitSha'
|
} from './commitSha'
|
||||||
import {getEnv} from './env'
|
import {getEnv} from './env'
|
||||||
import {getInputs} from './inputs'
|
import {getInputs} from './inputs'
|
||||||
import {
|
import {
|
||||||
getFilePatterns,
|
getFilePatterns,
|
||||||
|
getFilteredChangedFiles,
|
||||||
getSubmodulePath,
|
getSubmodulePath,
|
||||||
isRepoShallow,
|
isRepoShallow,
|
||||||
setOutput,
|
setOutput,
|
||||||
@ -105,16 +112,27 @@ export async function run(): Promise<void> {
|
|||||||
inputs,
|
inputs,
|
||||||
workingDirectory
|
workingDirectory
|
||||||
})
|
})
|
||||||
|
core.debug(`File patterns: ${filePatterns}`)
|
||||||
|
|
||||||
const addedFiles = await getDiffFiles({
|
const allDiffFiles = await getAllDiffFiles({
|
||||||
inputs,
|
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
hasSubmodule,
|
hasSubmodule,
|
||||||
diffResult,
|
diffResult,
|
||||||
diffFilter: 'A',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
submodulePaths
|
||||||
})
|
})
|
||||||
|
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`)
|
||||||
|
|
||||||
|
const allFilteredDiffFiles = await getFilteredChangedFiles({
|
||||||
|
allDiffFiles,
|
||||||
|
filePatterns
|
||||||
|
})
|
||||||
|
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`)
|
||||||
|
|
||||||
|
const addedFiles = await getChangeTypeFiles({
|
||||||
|
inputs,
|
||||||
|
changedFiles: allFilteredDiffFiles,
|
||||||
|
changeTypes: [ChangeTypeEnum.Added]
|
||||||
|
})
|
||||||
core.debug(`Added files: ${addedFiles}`)
|
core.debug(`Added files: ${addedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: 'added_files',
|
key: 'added_files',
|
||||||
@ -122,14 +140,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const copiedFiles = await getDiffFiles({
|
const copiedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Copied]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'C',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Copied files: ${copiedFiles}`)
|
core.debug(`Copied files: ${copiedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -138,14 +152,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const modifiedFiles = await getDiffFiles({
|
const modifiedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Modified]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'M',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Modified files: ${modifiedFiles}`)
|
core.debug(`Modified files: ${modifiedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -154,14 +164,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const renamedFiles = await getDiffFiles({
|
const renamedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Renamed]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'R',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Renamed files: ${renamedFiles}`)
|
core.debug(`Renamed files: ${renamedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -170,14 +176,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const typeChangedFiles = await getDiffFiles({
|
const typeChangedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.TypeChanged]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'T',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Type changed files: ${typeChangedFiles}`)
|
core.debug(`Type changed files: ${typeChangedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -186,14 +188,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const unmergedFiles = await getDiffFiles({
|
const unmergedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Unmerged]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'U',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Unmerged files: ${unmergedFiles}`)
|
core.debug(`Unmerged files: ${unmergedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -202,14 +200,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const unknownFiles = await getDiffFiles({
|
const unknownFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Unknown]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'X',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Unknown files: ${unknownFiles}`)
|
core.debug(`Unknown files: ${unknownFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -218,14 +212,9 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allChangedAndModifiedFiles = await getDiffFiles({
|
const allChangedAndModifiedFiles = await getAllChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles
|
||||||
hasSubmodule,
|
|
||||||
diffResult,
|
|
||||||
diffFilter: 'ACDMRTUX',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`)
|
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -234,14 +223,15 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allChangedFiles = await getDiffFiles({
|
const allChangedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMR',
|
ChangeTypeEnum.Copied,
|
||||||
filePatterns,
|
ChangeTypeEnum.Modified,
|
||||||
submodulePaths
|
ChangeTypeEnum.Renamed
|
||||||
|
]
|
||||||
})
|
})
|
||||||
core.debug(`All changed files: ${allChangedFiles}`)
|
core.debug(`All changed files: ${allChangedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -256,13 +246,15 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allOtherChangedFiles = await getDiffFiles({
|
const allOtherChangedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMR',
|
ChangeTypeEnum.Copied,
|
||||||
submodulePaths
|
ChangeTypeEnum.Modified,
|
||||||
|
ChangeTypeEnum.Renamed
|
||||||
|
]
|
||||||
})
|
})
|
||||||
core.debug(`All other changed files: ${allOtherChangedFiles}`)
|
core.debug(`All other changed files: ${allOtherChangedFiles}`)
|
||||||
|
|
||||||
@ -289,14 +281,16 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allModifiedFiles = await getDiffFiles({
|
const allModifiedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMRD',
|
ChangeTypeEnum.Copied,
|
||||||
filePatterns,
|
ChangeTypeEnum.Modified,
|
||||||
submodulePaths
|
ChangeTypeEnum.Renamed,
|
||||||
|
ChangeTypeEnum.Deleted
|
||||||
|
]
|
||||||
})
|
})
|
||||||
core.debug(`All modified files: ${allModifiedFiles}`)
|
core.debug(`All modified files: ${allModifiedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -311,13 +305,16 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allOtherModifiedFiles = await getDiffFiles({
|
const allOtherModifiedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [
|
||||||
diffResult,
|
ChangeTypeEnum.Added,
|
||||||
diffFilter: 'ACMRD',
|
ChangeTypeEnum.Copied,
|
||||||
submodulePaths
|
ChangeTypeEnum.Modified,
|
||||||
|
ChangeTypeEnum.Renamed,
|
||||||
|
ChangeTypeEnum.Deleted
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
const otherModifiedFiles = allOtherModifiedFiles
|
const otherModifiedFiles = allOtherModifiedFiles
|
||||||
@ -343,14 +340,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const deletedFiles = await getDiffFiles({
|
const deletedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allFilteredDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Deleted]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'D',
|
|
||||||
filePatterns,
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
core.debug(`Deleted files: ${deletedFiles}`)
|
core.debug(`Deleted files: ${deletedFiles}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -365,13 +358,10 @@ export async function run(): Promise<void> {
|
|||||||
inputs
|
inputs
|
||||||
})
|
})
|
||||||
|
|
||||||
const allOtherDeletedFiles = await getDiffFiles({
|
const allOtherDeletedFiles = await getChangeTypeFiles({
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory,
|
changedFiles: allDiffFiles,
|
||||||
hasSubmodule,
|
changeTypes: [ChangeTypeEnum.Deleted]
|
||||||
diffResult,
|
|
||||||
diffFilter: 'D',
|
|
||||||
submodulePaths
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const otherDeletedFiles = allOtherDeletedFiles
|
const otherDeletedFiles = allOtherDeletedFiles
|
||||||
|
81
src/utils.ts
81
src/utils.ts
@ -5,6 +5,7 @@ import {createReadStream, promises as fs} from 'fs'
|
|||||||
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 {ChangedFiles, ChangeTypeEnum} from './changedFiles'
|
||||||
|
|
||||||
import {Inputs} from './inputs'
|
import {Inputs} from './inputs'
|
||||||
|
|
||||||
@ -403,32 +404,28 @@ export const gitRenamedFiles = async ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const gitDiff = async ({
|
export const getAllChangedFiles = async ({
|
||||||
cwd,
|
cwd,
|
||||||
sha1,
|
sha1,
|
||||||
sha2,
|
sha2,
|
||||||
diff,
|
diff,
|
||||||
diffFilter,
|
|
||||||
filePatterns = [],
|
|
||||||
isSubmodule = false,
|
isSubmodule = false,
|
||||||
parentDir = ''
|
parentDir = ''
|
||||||
}: {
|
}: {
|
||||||
cwd: string
|
cwd: string
|
||||||
sha1: string
|
sha1: string
|
||||||
sha2: string
|
sha2: string
|
||||||
diffFilter: string
|
|
||||||
diff: string
|
diff: string
|
||||||
filePatterns?: string[]
|
|
||||||
isSubmodule?: boolean
|
isSubmodule?: boolean
|
||||||
parentDir?: string
|
parentDir?: string
|
||||||
}): Promise<string[]> => {
|
}): Promise<ChangedFiles> => {
|
||||||
const {exitCode, stdout, stderr} = await exec.getExecOutput(
|
const {exitCode, stdout, stderr} = await exec.getExecOutput(
|
||||||
'git',
|
'git',
|
||||||
[
|
[
|
||||||
'diff',
|
'diff',
|
||||||
'--name-only',
|
'--name-status',
|
||||||
'--ignore-submodules=all',
|
'--ignore-submodules=all',
|
||||||
`--diff-filter=${diffFilter}`,
|
`--diff-filter=ACDMRTUX`,
|
||||||
`${sha1}${diff}${sha2}`
|
`${sha1}${diff}${sha2}`
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
@ -437,6 +434,16 @@ export const gitDiff = async ({
|
|||||||
silent: process.env.RUNNER_DEBUG !== '1'
|
silent: process.env.RUNNER_DEBUG !== '1'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
const changedFiles: ChangedFiles = {
|
||||||
|
[ChangeTypeEnum.Added]: [],
|
||||||
|
[ChangeTypeEnum.Copied]: [],
|
||||||
|
[ChangeTypeEnum.Deleted]: [],
|
||||||
|
[ChangeTypeEnum.Modified]: [],
|
||||||
|
[ChangeTypeEnum.Renamed]: [],
|
||||||
|
[ChangeTypeEnum.TypeChanged]: [],
|
||||||
|
[ChangeTypeEnum.Unmerged]: [],
|
||||||
|
[ChangeTypeEnum.Unknown]: []
|
||||||
|
}
|
||||||
|
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
if (isSubmodule) {
|
if (isSubmodule) {
|
||||||
@ -453,28 +460,60 @@ export const gitDiff = async ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return []
|
return changedFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = stdout
|
const lines = stdout.split('\n').filter(Boolean)
|
||||||
.split('\n')
|
|
||||||
.filter(Boolean)
|
|
||||||
.map((p: string) => {
|
|
||||||
if (isSubmodule) {
|
|
||||||
return normalizePath(path.join(parentDir, p))
|
|
||||||
}
|
|
||||||
return normalizePath(p)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (filePatterns.length === 0) {
|
for (const line of lines) {
|
||||||
return files
|
const [changeType, filePath] = line.split('\t')
|
||||||
|
const normalizedFilePath = isSubmodule
|
||||||
|
? normalizePath(path.join(parentDir, filePath))
|
||||||
|
: normalizePath(filePath)
|
||||||
|
|
||||||
|
if (changeType.startsWith('R')) {
|
||||||
|
changedFiles[ChangeTypeEnum.Renamed].push(normalizedFilePath)
|
||||||
|
} else {
|
||||||
|
changedFiles[changeType as ChangeTypeEnum].push(normalizedFilePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changedFiles
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getFilteredChangedFiles = async ({
|
||||||
|
allDiffFiles,
|
||||||
|
filePatterns
|
||||||
|
}: {
|
||||||
|
allDiffFiles: ChangedFiles
|
||||||
|
filePatterns: string[]
|
||||||
|
}): Promise<ChangedFiles> => {
|
||||||
|
const changedFiles: ChangedFiles = {
|
||||||
|
[ChangeTypeEnum.Added]: [],
|
||||||
|
[ChangeTypeEnum.Copied]: [],
|
||||||
|
[ChangeTypeEnum.Deleted]: [],
|
||||||
|
[ChangeTypeEnum.Modified]: [],
|
||||||
|
[ChangeTypeEnum.Renamed]: [],
|
||||||
|
[ChangeTypeEnum.TypeChanged]: [],
|
||||||
|
[ChangeTypeEnum.Unmerged]: [],
|
||||||
|
[ChangeTypeEnum.Unknown]: []
|
||||||
}
|
}
|
||||||
|
|
||||||
return mm(files, filePatterns, {
|
for (const changeType of Object.keys(allDiffFiles)) {
|
||||||
|
const files = allDiffFiles[changeType as ChangeTypeEnum]
|
||||||
|
const hasFilePatterns = filePatterns.length > 0
|
||||||
|
|
||||||
|
if (hasFilePatterns) {
|
||||||
|
changedFiles[changeType as ChangeTypeEnum] = mm(files, filePatterns, {
|
||||||
dot: true,
|
dot: true,
|
||||||
windows: IS_WINDOWS,
|
windows: IS_WINDOWS,
|
||||||
noext: true
|
noext: true
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
changedFiles[changeType as ChangeTypeEnum] = files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return changedFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
export const gitLog = async ({
|
export const gitLog = async ({
|
||||||
|
@ -1 +1 @@
|
|||||||
This is a test file with non ascii character in the filename.
|
This is a test file with non ASCII character in the filename.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user