ScuttleBot

1
"use strict";
2
var __create = Object.create;
3
var __defProp = Object.defineProperty;
4
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
var __getOwnPropNames = Object.getOwnPropertyNames;
6
var __getProtoOf = Object.getPrototypeOf;
7
var __hasOwnProp = Object.prototype.hasOwnProperty;
8
var __export = (target, all) => {
9
for (var name in all)
10
__defProp(target, name, { get: all[name], enumerable: true });
11
};
12
var __copyProps = (to, from, except, desc) => {
13
if (from && typeof from === "object" || typeof from === "function") {
14
for (let key of __getOwnPropNames(from))
15
if (!__hasOwnProp.call(to, key) && key !== except)
16
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
}
18
return to;
19
};
20
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
// If the importer is in node compatibility mode or this is not an ESM
22
// file that has been converted to a CommonJS file using a Babel-
23
// compatible transform (i.e. "__esModule" has not been set), then set
24
// "default" to the CommonJS "module.exports" for node compatibility.
25
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
mod
27
));
28
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
var vcs_exports = {};
30
__export(vcs_exports, {
31
detectChangedTestFiles: () => detectChangedTestFiles
32
});
33
module.exports = __toCommonJS(vcs_exports);
34
var import_child_process = __toESM(require("child_process"));
35
var import_path = __toESM(require("path"));
36
var import_compilationCache = require("../transform/compilationCache");
37
async function detectChangedTestFiles(baseCommit, configDir) {
38
function gitFileList(command) {
39
try {
40
return import_child_process.default.execSync(
41
`git ${command}`,
42
{ encoding: "utf-8", stdio: "pipe", cwd: configDir }
43
).split("\n").filter(Boolean);
44
} catch (_error) {
45
const error = _error;
46
const unknownRevision = error.output.some((line) => line?.includes("unknown revision"));
47
if (unknownRevision) {
48
const isShallowClone = import_child_process.default.execSync("git rev-parse --is-shallow-repository", { encoding: "utf-8", stdio: "pipe", cwd: configDir }).trim() === "true";
49
if (isShallowClone) {
50
throw new Error([
51
`The repository is a shallow clone and does not have '${baseCommit}' available locally.`,
52
`Note that GitHub Actions checkout is shallow by default: https://github.com/actions/checkout`
53
].join("\n"));
54
}
55
}
56
throw new Error([
57
`Cannot detect changed files for --only-changed mode:`,
58
`git ${command}`,
59
"",
60
...error.output
61
].join("\n"));
62
}
63
}
64
const untrackedFiles = gitFileList(`ls-files --others --exclude-standard`).map((file) => import_path.default.join(configDir, file));
65
const [gitRoot] = gitFileList("rev-parse --show-toplevel");
66
const trackedFilesWithChanges = gitFileList(`diff ${baseCommit} --name-only`).map((file) => import_path.default.join(gitRoot, file));
67
return new Set((0, import_compilationCache.affectedTestFiles)([...untrackedFiles, ...trackedFilesWithChanges]));
68
}
69
// Annotate the CommonJS export names for ESM import in node:
70
0 && (module.exports = {
71
detectChangedTestFiles
72
});
73

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button