@okfit/profiles 0.10.5 → 0.11.0
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/Derivation.js +24 -3
- package/index.d.ts +13 -2
- package/package.json +4 -4
- package/tsdoc-metadata.json +1 -1
package/Derivation.js
CHANGED
|
@@ -165,9 +165,30 @@ var Derivation = class Derivation {
|
|
|
165
165
|
*/
|
|
166
166
|
static contentDigest = contentDigest;
|
|
167
167
|
/**
|
|
168
|
+
* The worktree root holding `start`: the nearest ancestor directory (inclusive) with a `.git` entry, a
|
|
169
|
+
* directory in a main checkout and a file in a linked worktree or submodule; `undefined` when none has one.
|
|
170
|
+
* Asked of the filesystem rather than of `git rev-parse --show-toplevel` because a pre-commit hook in a
|
|
171
|
+
* linked worktree exports `GIT_DIR` without `GIT_WORK_TREE`, and git then takes each call's cwd as the
|
|
172
|
+
* worktree, naming whatever directory it was asked from as the top level (okfit #315). Not
|
|
173
|
+
* symlink-resolved; callers `realPath` it as they would `Git.repoRoot`.
|
|
174
|
+
*/
|
|
175
|
+
static worktreeRoot = Effect.fn("Derivation.worktreeRoot")(function* (start) {
|
|
176
|
+
const fs = yield* FileSystem.FileSystem;
|
|
177
|
+
const path = yield* Path.Path;
|
|
178
|
+
let dir = path.resolve(start);
|
|
179
|
+
for (;;) {
|
|
180
|
+
if (yield* fs.exists(path.join(dir, ".git")).pipe(Effect.orElseSucceed(() => false))) return dir;
|
|
181
|
+
const parent = path.dirname(dir);
|
|
182
|
+
if (parent === dir) return void 0;
|
|
183
|
+
dir = parent;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
/**
|
|
168
187
|
* Spec 5.4 rule 2 as P-2 (DERIVE option C). Steps:
|
|
169
|
-
* 1. `root = Git.repoRoot(dirname(file))`:
|
|
170
|
-
*
|
|
188
|
+
* 1. `root = worktreeRoot(dirname(file)) ?? Git.repoRoot(dirname(file))`: the filesystem walk first, so a
|
|
189
|
+
* linked worktree's hook environment (`GIT_DIR` exported) cannot shrink the root to the file's directory
|
|
190
|
+
* (okfit #315); git answers when no ancestor holds `.git`, and a file outside any repository surfaces
|
|
191
|
+
* `NotARepositoryError`. Submodules and worktrees work because both are asked from the file's directory (P-39).
|
|
171
192
|
* 2. `realPath` both (rev-parse is symlink-resolved), then the repo-relative posix path via `Path` (P-39).
|
|
172
193
|
* 3. `worktree = body(readFileString(file))`.
|
|
173
194
|
* 4. `Git.show(realRoot, "HEAD", rel)`: `UnknownRefError` is `uncommitted { unborn }` (P-11), `Option.none`
|
|
@@ -186,7 +207,7 @@ var Derivation = class Derivation {
|
|
|
186
207
|
const history = yield* GitHistory;
|
|
187
208
|
const fs = yield* FileSystem.FileSystem;
|
|
188
209
|
const path = yield* Path.Path;
|
|
189
|
-
const root = yield* git.repoRoot(path.dirname(options.file));
|
|
210
|
+
const root = (yield* Derivation.worktreeRoot(path.dirname(options.file))) ?? (yield* git.repoRoot(path.dirname(options.file)));
|
|
190
211
|
const realRoot = yield* fs.realPath(root);
|
|
191
212
|
const realFile = yield* fs.realPath(options.file);
|
|
192
213
|
const rel = path.relative(realRoot, realFile).split(path.sep).join("/");
|
package/index.d.ts
CHANGED
|
@@ -306,10 +306,21 @@ export declare class Derivation {
|
|
|
306
306
|
* plus the normalised body, insensitive to style, key order and CRLF.
|
|
307
307
|
*/
|
|
308
308
|
static readonly contentDigest: (raw: Readonly<Record<string, unknown>>, source: string) => Effect.Effect<Digest, PlatformError.PlatformError, Crypto.Crypto>;
|
|
309
|
+
/**
|
|
310
|
+
* The worktree root holding `start`: the nearest ancestor directory (inclusive) with a `.git` entry, a
|
|
311
|
+
* directory in a main checkout and a file in a linked worktree or submodule; `undefined` when none has one.
|
|
312
|
+
* Asked of the filesystem rather than of `git rev-parse --show-toplevel` because a pre-commit hook in a
|
|
313
|
+
* linked worktree exports `GIT_DIR` without `GIT_WORK_TREE`, and git then takes each call's cwd as the
|
|
314
|
+
* worktree, naming whatever directory it was asked from as the top level (okfit #315). Not
|
|
315
|
+
* symlink-resolved; callers `realPath` it as they would `Git.repoRoot`.
|
|
316
|
+
*/
|
|
317
|
+
static readonly worktreeRoot: (start: string) => Effect.Effect<string | undefined, never, FileSystem.FileSystem | Path.Path>;
|
|
309
318
|
/**
|
|
310
319
|
* Spec 5.4 rule 2 as P-2 (DERIVE option C). Steps:
|
|
311
|
-
* 1. `root = Git.repoRoot(dirname(file))`:
|
|
312
|
-
*
|
|
320
|
+
* 1. `root = worktreeRoot(dirname(file)) ?? Git.repoRoot(dirname(file))`: the filesystem walk first, so a
|
|
321
|
+
* linked worktree's hook environment (`GIT_DIR` exported) cannot shrink the root to the file's directory
|
|
322
|
+
* (okfit #315); git answers when no ancestor holds `.git`, and a file outside any repository surfaces
|
|
323
|
+
* `NotARepositoryError`. Submodules and worktrees work because both are asked from the file's directory (P-39).
|
|
313
324
|
* 2. `realPath` both (rev-parse is symlink-resolved), then the repo-relative posix path via `Path` (P-39).
|
|
314
325
|
* 3. `worktree = body(readFileString(file))`.
|
|
315
326
|
* 4. `Git.show(realRoot, "HEAD", rel)`: `UnknownRefError` is `uncommitted { unborn }` (P-11), `Option.none`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okfit/profiles",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Named OKF configuration profiles for okfit, starting with the software-project profile.",
|
|
6
6
|
"keywords": [
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"./package.json": "./package.json"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@effected/git": "^0.
|
|
39
|
-
"@effected/markdown": "^0.
|
|
40
|
-
"@okfit/core": "^0.11.
|
|
38
|
+
"@effected/git": "^0.25.0",
|
|
39
|
+
"@effected/markdown": "^0.23.0",
|
|
40
|
+
"@okfit/core": "^0.11.6",
|
|
41
41
|
"effect": "^4.0.0"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|