podster 0.0.1-test.12 → 0.0.1-test.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/core/repository.js +36 -2
- package/build/node/repo-path.js +24 -7
- package/package.json +1 -1
package/build/core/repository.js
CHANGED
|
@@ -63,8 +63,42 @@ export const RENEW_BEFORE_MS = 4 * 60 * 1000;
|
|
|
63
63
|
* repository tracks under one of them is still committed as usual: an exclude applies only to untracked files.
|
|
64
64
|
*/
|
|
65
65
|
export const WORK_TREE_CACHES = [".cache", ".cargo", ".npm-global"];
|
|
66
|
-
/**
|
|
67
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Runner's default ignore list, written into its own `info/exclude` after the cache folders and applied to every
|
|
68
|
+
* repository whatever its `.gitignore` says, so a repository with none can still publish after an install and never
|
|
69
|
+
* commits what an agent leaves behind:
|
|
70
|
+
* - dependency folders that hold links: `node_modules/` and `.venv/` at any depth (a monorepo nests them);
|
|
71
|
+
* - Python's `__pycache__/` and `.pytest_cache/` at any depth;
|
|
72
|
+
* - at the top only: cargo's build folder `/target/`, wrangler's local state `/.wrangler/`, and agents' scratch `/.tmp/`;
|
|
73
|
+
* - `.DS_Store` at any depth;
|
|
74
|
+
* - `.env` and `.env.*` at any depth, except `.env.example`, `.env.sample` and `.env.template`, so an agent-written
|
|
75
|
+
* `.env` is never committed.
|
|
76
|
+
* Folder lines end in `/`, so a link by one of those names isn't excluded and the work tree check still refuses it; a
|
|
77
|
+
* folder Git then ignores whole is skipped by that check (`ignoredFolders`), unless another ignored entry is listed
|
|
78
|
+
* beneath it (`wholeFolders`), so an excluded `.env` that is a link is always reached and refuses, at any depth. An exclude applies only to untracked files:
|
|
79
|
+
* a file the repository tracks under or by one of these names is still committed as usual, and a folder holding one is
|
|
80
|
+
* walked by the work tree check as before.
|
|
81
|
+
*/
|
|
82
|
+
export const WORK_TREE_DEFAULT_IGNORE = [
|
|
83
|
+
"node_modules/",
|
|
84
|
+
".venv/",
|
|
85
|
+
"__pycache__/",
|
|
86
|
+
".pytest_cache/",
|
|
87
|
+
"/target/",
|
|
88
|
+
"/.wrangler/",
|
|
89
|
+
"/.tmp/",
|
|
90
|
+
".DS_Store",
|
|
91
|
+
".env",
|
|
92
|
+
".env.*",
|
|
93
|
+
"!.env.example",
|
|
94
|
+
"!.env.sample",
|
|
95
|
+
"!.env.template",
|
|
96
|
+
];
|
|
97
|
+
/**
|
|
98
|
+
* The `info/exclude` Runner writes: each cache folder, anchored at the work tree's top, as a folder only, then the
|
|
99
|
+
* default ignore list (`WORK_TREE_DEFAULT_IGNORE`) as written there.
|
|
100
|
+
*/
|
|
101
|
+
export const WORK_TREE_EXCLUDE = [...WORK_TREE_CACHES.map((name) => `/${name}/`), ...WORK_TREE_DEFAULT_IGNORE].map((line) => `${line}\n`).join("");
|
|
68
102
|
/** The prefix of every task branch. */
|
|
69
103
|
export const BRANCH_PREFIX = "podster/";
|
|
70
104
|
/** The fixed identity of a commit Runner makes, so no name or address from anywhere else is ever used. */
|
package/build/node/repo-path.js
CHANGED
|
@@ -155,8 +155,10 @@ export class GitRepositoryPath {
|
|
|
155
155
|
return this.deps.git([...hardening(helper), ...locate(this.gitDir(task.workspace_id, task.task_id), task.task_folder), ...args], { secret: opts.secret, signal: opts.signal, timeout_ms: opts.timeout_ms });
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
|
-
* Runner's own `info/exclude` in the task's Git folder: the tools' cache folders (`WORK_TREE_CACHES`)
|
|
159
|
-
*
|
|
158
|
+
* Runner's own `info/exclude` in the task's Git folder: the tools' cache folders (`WORK_TREE_CACHES`) and the default
|
|
159
|
+
* ignore list (`WORK_TREE_DEFAULT_IGNORE`: dependency folders, build output, scratch, `.DS_Store` and `.env` files), so
|
|
160
|
+
* nothing untracked there is ever committed, and `ignoredFolders` names the folders so the work tree check skips them.
|
|
161
|
+
* A tracked file under one is still committed. Written at checkout, and again before a publish if it isn't exactly that.
|
|
160
162
|
*/
|
|
161
163
|
async excludeCaches(task) {
|
|
162
164
|
const gitDir = this.gitDir(task.workspace_id, task.task_id);
|
|
@@ -384,20 +386,35 @@ export function nameOf(bytes) {
|
|
|
384
386
|
* The folders in `git ls-files -z --others --ignored --directory`'s answer, read as bytes, relative to the work tree's
|
|
385
387
|
* top: only entries Git names with a trailing `/`, which it does for a folder it ignores whole. Any entry that isn't
|
|
386
388
|
* valid UTF-8 refuses. An ignored file, a link Git ignores (Git names a link as a file), and anything with an empty,
|
|
387
|
-
* `.` or `..` part are left out, so they are walked.
|
|
389
|
+
* `.` or `..` part are left out, so they are walked. A folder with any other listed entry beneath it is left out too
|
|
390
|
+
* (the review of #508): when everything in a folder is ignored, Git lists the folder and also the ignored entries in
|
|
391
|
+
* it (`f/` and `f/.env`, `x/` and `x/node_modules/`), so skipping `f` would never `lstat` a link `f/.env`, and skipping
|
|
392
|
+
* `x` would never read the entries of `x/node_modules`, where a `.git` look-alike must refuse. Such a parent is walked
|
|
393
|
+
* as usual, and only the deepest listed folders are skipped.
|
|
388
394
|
*/
|
|
389
395
|
export function wholeFolders(listing) {
|
|
390
|
-
const
|
|
396
|
+
const entries = [];
|
|
391
397
|
const bytes = Buffer.from(listing.buffer, listing.byteOffset, listing.byteLength);
|
|
392
398
|
for (let at = 0; at < bytes.length;) {
|
|
393
399
|
const end = bytes.indexOf(0, at);
|
|
394
|
-
|
|
400
|
+
entries.push(nameOf(bytes.subarray(at, end === -1 ? bytes.length : end)));
|
|
395
401
|
at = end === -1 ? bytes.length : end + 1;
|
|
402
|
+
}
|
|
403
|
+
// Every folder some listed entry lies beneath, whatever that entry is.
|
|
404
|
+
const parents = new Set();
|
|
405
|
+
for (const entry of entries) {
|
|
406
|
+
const trimmed = entry.endsWith("/") ? entry.slice(0, -1) : entry;
|
|
407
|
+
for (let slash = trimmed.indexOf("/"); slash !== -1; slash = trimmed.indexOf("/", slash + 1))
|
|
408
|
+
parents.add(trimmed.slice(0, slash));
|
|
409
|
+
}
|
|
410
|
+
const folders = new Set();
|
|
411
|
+
for (const entry of entries) {
|
|
396
412
|
if (!entry.endsWith("/"))
|
|
397
413
|
continue;
|
|
398
414
|
const parts = entry.slice(0, -1).split("/");
|
|
399
|
-
|
|
400
|
-
|
|
415
|
+
const name = parts.join("/");
|
|
416
|
+
if (parts.every((part) => part !== "" && part !== "." && part !== "..") && !parents.has(name))
|
|
417
|
+
folders.add(name);
|
|
401
418
|
}
|
|
402
419
|
return folders;
|
|
403
420
|
}
|