@okfit/profiles 0.12.0 → 0.13.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 CHANGED
@@ -5,7 +5,6 @@ import { Actor, OkfitConfig } from "@okfit/core";
5
5
  import { DateTime, Duration, Effect, FileSystem, Option, Path, Schema } from "effect";
6
6
  import { Git } from "@effected/git";
7
7
  import { JsoncFingerprint } from "@effected/jsonc";
8
- import { Walker } from "@effected/walker";
9
8
 
10
9
  // src/Derivation.ts
11
10
  /**
@@ -162,26 +161,12 @@ var Derivation = class Derivation {
162
161
  */
163
162
  static contentDigest = contentDigest;
164
163
  /**
165
- * The worktree root holding `start`: the nearest ancestor directory (inclusive) with a `.git` entry, a
166
- * directory in a main checkout and a file in a linked worktree or submodule; `undefined` when none has one.
167
- * Asked of the filesystem rather than of `git rev-parse --show-toplevel` because a pre-commit hook in a
168
- * linked worktree exports `GIT_DIR` without `GIT_WORK_TREE`, and git then takes each call's cwd as the
169
- * worktree, naming whatever directory it was asked from as the top level (okfit #315). Not
170
- * symlink-resolved; callers `realPath` it as they would `Git.repoRoot`.
171
- */
172
- static worktreeRoot = Effect.fn("Derivation.worktreeRoot")(function* (start) {
173
- const fs = yield* FileSystem.FileSystem;
174
- const path = yield* Path.Path;
175
- const dirs = yield* Walker.ascend(path.resolve(start));
176
- const root = yield* Walker.findRoot(dirs, (dir) => fs.exists(path.join(dir, ".git")));
177
- return Option.getOrUndefined(root);
178
- });
179
- /**
180
164
  * Spec 5.4 rule 2 as P-2 (DERIVE option C). Steps:
181
- * 1. `root = worktreeRoot(dirname(file)) ?? Git.repoRoot(dirname(file))`: the filesystem walk first, so a
182
- * linked worktree's hook environment (`GIT_DIR` exported) cannot shrink the root to the file's directory
183
- * (okfit #315); git answers when no ancestor holds `.git`, and a file outside any repository surfaces
184
- * `NotARepositoryError`. Submodules and worktrees work because both are asked from the file's directory (P-39).
165
+ * 1. `root = Git.repoRoot(dirname(file), { ignoreRepositoryEnv: true })`: the option drops the
166
+ * repository-pointing variables (`GIT_DIR` and kin), so a linked worktree's hook environment cannot shrink
167
+ * the root to the file's directory (okfit #315). On `NotARepositoryError` it retries with that
168
+ * environment honoured, so a repository defined only by `GIT_DIR`/`GIT_WORK_TREE` still resolves; a file
169
+ * outside any repository surfaces `NotARepositoryError`. Submodules and worktrees work because both are asked from the file's directory (P-39).
185
170
  * 2. `realPath` both (rev-parse is symlink-resolved), then the repo-relative posix path via `Path` (P-39).
186
171
  * 3. `worktree = body(readFileString(file))`.
187
172
  * 4. `Git.show(realRoot, "HEAD", rel)`: `UnknownRefError` is `uncommitted { unborn }` (P-11), `Option.none`
@@ -200,7 +185,8 @@ var Derivation = class Derivation {
200
185
  const history = yield* GitHistory;
201
186
  const fs = yield* FileSystem.FileSystem;
202
187
  const path = yield* Path.Path;
203
- const root = (yield* Derivation.worktreeRoot(path.dirname(options.file))) ?? (yield* git.repoRoot(path.dirname(options.file)));
188
+ const dir = path.dirname(options.file);
189
+ const root = yield* git.repoRoot(dir, { ignoreRepositoryEnv: true }).pipe(Effect.catchTag("NotARepositoryError", () => git.repoRoot(dir)));
204
190
  const realRoot = yield* fs.realPath(root);
205
191
  const realFile = yield* fs.realPath(options.file);
206
192
  const rel = path.relative(realRoot, realFile).split(path.sep).join("/");
package/index.d.ts CHANGED
@@ -306,21 +306,13 @@ 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>;
318
309
  /**
319
310
  * Spec 5.4 rule 2 as P-2 (DERIVE option C). Steps:
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).
311
+ * 1. `root = Git.repoRoot(dirname(file), { ignoreRepositoryEnv: true })`: the option drops the
312
+ * repository-pointing variables (`GIT_DIR` and kin), so a linked worktree's hook environment cannot shrink
313
+ * the root to the file's directory (okfit #315). On `NotARepositoryError` it retries with that
314
+ * environment honoured, so a repository defined only by `GIT_DIR`/`GIT_WORK_TREE` still resolves; a file
315
+ * outside any repository surfaces `NotARepositoryError`. Submodules and worktrees work because both are asked from the file's directory (P-39).
324
316
  * 2. `realPath` both (rev-parse is symlink-resolved), then the repo-relative posix path via `Path` (P-39).
325
317
  * 3. `worktree = body(readFileString(file))`.
326
318
  * 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.12.0",
3
+ "version": "0.13.0",
4
4
  "private": false,
5
5
  "description": "Named OKF configuration profiles for okfit, starting with the software-project profile.",
6
6
  "keywords": [
@@ -35,12 +35,13 @@
35
35
  "./package.json": "./package.json"
36
36
  },
37
37
  "peerDependencies": {
38
- "@effected/git": "^0.26.0",
39
- "@effected/glob": "^0.15.0",
40
- "@effected/jsonc": "^0.20.0",
41
- "@effected/markdown": "^0.23.0",
42
- "@effected/walker": "^0.21.0",
43
- "@okfit/core": "^0.11.7",
38
+ "@effected/git": "^0.27.0",
39
+ "@effected/glob": "^0.16.0",
40
+ "@effected/jsonc": "^0.21.0",
41
+ "@effected/markdown": "^0.24.0",
42
+ "@effected/source": "^0.1.0",
43
+ "@effected/walker": "^0.22.0",
44
+ "@okfit/core": "^0.11.8",
44
45
  "effect": "^4.0.0"
45
46
  },
46
47
  "engines": {
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.4"
8
+ "packageVersion": "7.60.0"
9
9
  }
10
10
  ]
11
11
  }