@hawkeyexl/manni 2.11.1 → 2.12.1

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/README.md CHANGED
@@ -98,7 +98,7 @@ actually reads rather than hand-written:
98
98
  ```yaml
99
99
  repos:
100
100
  - repo: https://github.com/hawkeyexl/manni
101
- rev: v2.11.1
101
+ rev: v2.12.1
102
102
  hooks:
103
103
  - id: manni-meta
104
104
  ```
@@ -81,7 +81,7 @@ import {
81
81
  withValueAt,
82
82
  writeEncryptionKey,
83
83
  writeFileAtomic
84
- } from "./chunk-7ODP2AB3.js";
84
+ } from "./chunk-F6CE4LEJ.js";
85
85
 
86
86
  // src/meta/core/reencrypt.ts
87
87
  import { extname } from "node:path";
@@ -1900,6 +1900,19 @@ function gitClient(root) {
1900
1900
  });
1901
1901
  return {
1902
1902
  available,
1903
+ shallow,
1904
+ // `merge-base --is-ancestor` exits 0 for yes and 1 for no. For a commit
1905
+ // it does not have it exits 128, `Not a valid commit name`, which reads
1906
+ // as git failing. So `hasCommit` answers first, and is required rather
1907
+ // than an optimization: a commit git lacks is in no history it holds,
1908
+ // which is a no, and exactly the pin a deleted branch leaves behind.
1909
+ isAncestor: (commit, of) => once(`ancestor\0${commit}\0${of}`, async () => {
1910
+ if (!await hasCommit(commit)) return false;
1911
+ const out = await run2(root, ["merge-base", "--is-ancestor", "--end-of-options", commit, of]);
1912
+ if (out.ok) return true;
1913
+ if (out.code === 1) return false;
1914
+ throw failed("merge-base", out);
1915
+ }),
1903
1916
  head: () => once("head", async () => {
1904
1917
  if (!await available()) return null;
1905
1918
  const out = await run2(root, ["rev-parse", "HEAD"]);
@@ -1966,6 +1979,7 @@ function gitClient(root) {
1966
1979
  var UNIT = "";
1967
1980
  var GIT_UNAVAILABLE_HISTORY = "git is not available here, so citations are checked without history: no never-true, no reanchored claims, no diffs, no commit subjects.";
1968
1981
  var PAGE_HISTORY_UNAVAILABLE = "the page history ends before the pin held; use fetch-depth: 0 to tell reanchored claims from changed ones";
1982
+ var SHALLOW_RECOMMIT = "this clone is shallow, so --recommit re-recorded only commits that do not contain their lines. Fetch full history to check the rest.";
1969
1983
  var GIT_UNAVAILABLE_COMMIT = "git is not available here, so the citation records no commit.";
1970
1984
  function noGit() {
1971
1985
  return {
@@ -4806,6 +4820,7 @@ function rewriteOf(plan) {
4806
4820
  reason: "recommitted",
4807
4821
  // The source itself held. Only its date was wrong.
4808
4822
  status: "current",
4823
+ because: plan.because,
4809
4824
  from: plan.from,
4810
4825
  to: plan.commitSha,
4811
4826
  fromCommit: plan.from,
@@ -5017,19 +5032,29 @@ async function runUpdate(opts) {
5017
5032
  "--recommit needs git to verify recorded commits, and git is not available here."
5018
5033
  );
5019
5034
  }
5035
+ const outsideHistory = async (commit, head) => {
5036
+ if (git.shallow === void 0 || git.isAncestor === void 0) return false;
5037
+ if (await git.shallow()) return false;
5038
+ return !await git.isAncestor(commit, head);
5039
+ };
5020
5040
  const recommitFor = async (result) => {
5021
5041
  const recorded = result.citation.source["commit-sha"];
5022
5042
  const path = result.source.resolvedPath;
5023
5043
  if (recorded === void 0 || path === void 0) return void 0;
5044
+ const head = await git.head();
5045
+ if (head === null || head === recorded) return void 0;
5024
5046
  const range = sourceRange(result.citation.source);
5025
5047
  const pin = result.citation.source.integrity;
5026
5048
  const key = range.encrypted ? run3.key : void 0;
5027
- const was = await historyOf(git, recorded, path, range, pin, key, void 0);
5028
- if (was.kind !== "never-true") return void 0;
5029
- const head = await git.head();
5030
- if (head === null || head === recorded) return void 0;
5049
+ let because;
5050
+ if (await outsideHistory(recorded, head)) because = "not-in-history";
5051
+ else {
5052
+ const was = await historyOf(git, recorded, path, range, pin, key, void 0);
5053
+ if (was.kind !== "never-true") return void 0;
5054
+ because = "not-contained";
5055
+ }
5031
5056
  const now = await historyOf(git, head, path, range, pin, key, void 0);
5032
- return now.kind === "original" ? head : void 0;
5057
+ return now.kind === "original" ? { commit: head, because } : void 0;
5033
5058
  };
5034
5059
  const plansFor = async (result, entry, page, lines, lineNow, declined) => {
5035
5060
  const out = [];
@@ -5129,7 +5154,8 @@ async function runUpdate(opts) {
5129
5154
  kind: "source-recommitted",
5130
5155
  result,
5131
5156
  from: result.citation.source["commit-sha"] ?? "",
5132
- commitSha: to
5157
+ commitSha: to.commit,
5158
+ because: to.because
5133
5159
  });
5134
5160
  }
5135
5161
  }
@@ -5444,7 +5470,12 @@ async function runUpdate(opts) {
5444
5470
  const reminted = pages.some(
5445
5471
  (page) => page.rewritten.some((r) => r.reason === "accepted" && r.end === "source")
5446
5472
  );
5447
- sayNotices(reports, opts.onNotice, reminted && !await git.available() ? [GIT_UNAVAILABLE_COMMIT] : []);
5473
+ const also = [];
5474
+ if (reminted && !await git.available()) also.push(GIT_UNAVAILABLE_COMMIT);
5475
+ if (recommit && git.shallow !== void 0 && git.isAncestor !== void 0 && await git.shallow()) {
5476
+ also.push(SHALLOW_RECOMMIT);
5477
+ }
5478
+ sayNotices(reports, opts.onNotice, also);
5448
5479
  const rewritten = pages.reduce((n, page) => n + citationsIn(page.rewritten), 0);
5449
5480
  const skipped = pages.reduce((n, page) => n + page.skipped.length + page.refused.length, 0);
5450
5481
  const undone = pages.some(
@@ -5871,6 +5902,15 @@ function refusalLine(rewrite) {
5871
5902
  }
5872
5903
  return `${where} that line now holds different text than the claim at ${at2}. Re-add it with cite add.`;
5873
5904
  }
5905
+ function recommitWhy(because) {
5906
+ switch (because) {
5907
+ case "not-in-history":
5908
+ return "not in this branch's history";
5909
+ case "not-contained":
5910
+ case void 0:
5911
+ return "did not contain the pinned lines";
5912
+ }
5913
+ }
5874
5914
  function rewriteLine(rewrite) {
5875
5915
  const word = rewrite.from.includes("-") ? "lines" : "line";
5876
5916
  const status = rewrite.status === "never-true" ? "never true" : rewrite.status;
@@ -5880,7 +5920,7 @@ function rewriteLine(rewrite) {
5880
5920
  if (rewrite.reason === "recommitted") {
5881
5921
  const from = shortCommit(rewrite.fromCommit ?? "");
5882
5922
  const to = shortCommit(rewrite.toCommit ?? "");
5883
- return `source ${shortSrc(rewrite.src ?? "")} commit ${from} -> ${to} (did not contain the pinned lines)`;
5923
+ return `source ${shortSrc(rewrite.src ?? "")} commit ${from} -> ${to} (${recommitWhy(rewrite.because)})`;
5884
5924
  }
5885
5925
  if (rewrite.reason === "shifted") {
5886
5926
  return `claim ${word} ${rewrite.from} -> ${rewrite.to} (shifted by a marker)`;
@@ -6578,4 +6618,4 @@ export {
6578
6618
  runKeyRotate,
6579
6619
  runKeySet
6580
6620
  };
6581
- //# sourceMappingURL=chunk-CZGAZGDN.js.map
6621
+ //# sourceMappingURL=chunk-7X4QMQX4.js.map