@afokapu/atdd-bun 0.7.1 → 0.7.2

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/integrity.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.1",
2
+ "version": "0.7.2",
3
3
  "files": {
4
4
  "HOOK_AUDIT.md": "5329d840db37671b1918f688ead26865473b87db73dbc75f7c8b2a8bbe8d6d43",
5
5
  "PLANNER_PORT.md": "fb5935bac8b7ac18994de21e43ace3a5ef8cd55f85b0e3349fca261280054f11",
@@ -1175,7 +1175,7 @@
1175
1175
  "src/enforce.ts": "d7232331c9f0fdd150f2ca4bbf1bd2e877de111c684d46b690fd7acdae59f39c",
1176
1176
  "src/hooks.ts": "adbb72f7a83f53d596fd217f01f4ce32c5a59a23ab81993fed226fb96fd1cbd1",
1177
1177
  "src/index.ts": "b3cc97f9867bd605aefa95650a6b8b773e32e6e52e58792d0dbf6736dd3406be",
1178
- "src/integrity.ts": "fddc8abd1ca039d31584d3288c061badd44c5f8300f62db5861ea6bb0ebf95d9",
1178
+ "src/integrity.ts": "c1ef78d93f418f50b15178de939c21e480ed49420c003d75e1c344ecbb95ce5b",
1179
1179
  "src/journey-docs.ts": "994d229376244c84212cff951032823068a76565dd2fd427b9d44e341bd14853",
1180
1180
  "src/planner-kernel.ts": "5d3f5305fb59becb2cc97d8a03aca6b104f385805d91cc0410856e289dd6fbb1",
1181
1181
  "src/planner-schema-validator.ts": "ce529c0936171075e93c7539b3655fe895a98dd2973ebda5775958e6ebc316d9",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afokapu/atdd-bun",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/afokapu/atdd-bun.git"
package/src/integrity.ts CHANGED
@@ -130,6 +130,14 @@ export function loosenedPolicy(base: Partial<HookPolicy> & { profiles?: unknown
130
130
  }
131
131
 
132
132
  /** atdd-bun.yaml is not looser than on the branch being merged into. */
133
+ /** How to recover a baseline that cannot be resolved. A replaced tip is reachable from no branch, so only a fetch by its
134
+ * full object id brings it back (SHA-1 or SHA-256, any case); an abbreviated id cannot be fetched; a ref name can. */
135
+ export function baselineRestore(ref: string): string {
136
+ if (/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i.test(ref)) return `git fetch origin ${ref}, then re-run the check (a replaced tip is reachable from no branch, so a plain fetch does not bring it)`;
137
+ if (/^[0-9a-f]{4,63}$/i.test(ref)) return `set ATDD_BASE_REF to the full SHA of ${ref} (an abbreviated SHA cannot be fetched), fetch it with git fetch origin <full SHA>, then re-run the check`;
138
+ return `git fetch origin, then re-run the check`;
139
+ }
140
+
133
141
  async function checkPolicy(root: string, base?: string, push = process.env.GITHUB_EVENT_NAME === "push"): Promise<IntegrityFinding[]> {
134
142
  // On a push, the generated CI passes the pre-push tip (github.event.before) as ATDD_BASE_REF, so a multi-commit push
135
143
  // is judged as a whole: [docs, security] → no list → [docs] in one push cannot read as a first adoption.
@@ -137,7 +145,7 @@ async function checkPolicy(root: string, base?: string, push = process.env.GITHU
137
145
  const newBranch = /^0+$/.test(ref), resolved = newBranch ? "" : (await git(root, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`])).out;
138
146
  let against: string;
139
147
  // An explicit baseline (the pre-push tip, the merge queue's target) that cannot be resolved fails closed.
140
- if (!newBranch && !resolved && (base || process.env.ATDD_BASE_REF)) return [{ file: "atdd-bun.yaml", detail: `cannot resolve the policy baseline ${ref.slice(0, 7)} to judge this change against; fetch it (fetch-depth: 0)`, restore: "git fetch origin && re-run the check" }];
148
+ if (!newBranch && !resolved && (base || process.env.ATDD_BASE_REF)) return [{ file: "atdd-bun.yaml", detail: `cannot resolve the policy baseline ${ref} to judge this change against`, restore: baselineRestore(ref) }];
141
149
  if (push) {
142
150
  // A push is judged against the tip it replaced, directly, never a merge base: after a force push the merge base
143
151
  // can predate the policy being removed. A new branch has no previous tip and is judged against its parent.