walkdiff 0.4.0 → 0.6.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.
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Walkdiff review</title>
7
- <script type="module" crossorigin src="./assets/index-GjC9TYrP.js"></script>
8
- <link rel="stylesheet" crossorigin href="./assets/index-Dz8FNp8V.css">
7
+ <script type="module" crossorigin src="./assets/index-D1vvUwVU.js"></script>
8
+ <link rel="stylesheet" crossorigin href="./assets/index-BjF-nSXK.css">
9
9
  </head>
10
10
  <body>
11
11
  <!-- Replaced when the script starts, so a script that never runs is not a blank page. -->
package/walkdiff.mjs CHANGED
@@ -304,12 +304,14 @@ const unitChangeSchema = z.discriminatedUnion("kind", [
304
304
  z.object({
305
305
  kind: z.literal(UnitChangeKind.MovedIn),
306
306
  from: unitLocationSchema,
307
+ edited: z.boolean().default(false),
307
308
  before: unitSnapshotSchema,
308
309
  after: unitSnapshotSchema
309
310
  }),
310
311
  z.object({
311
312
  kind: z.literal(UnitChangeKind.MovedOut),
312
313
  to: unitLocationSchema,
314
+ edited: z.boolean().default(false),
313
315
  before: unitSnapshotSchema
314
316
  })
315
317
  ]);
@@ -755,14 +757,17 @@ function totalsOf(rows) {
755
757
  function changedUnitsOf(file) {
756
758
  return file.syntax.status === SyntaxAnalysisStatus.Analyzed ? file.syntax.units : [];
757
759
  }
758
- /** False for formatting, comments, renames and moves, which leave behaviour as it was. */
760
+ /**
761
+ * False for formatting, comments, renames and unedited moves, which leave behaviour as it was.
762
+ * An edited move counts once, where the unit arrived: the side it left has nothing new to read.
763
+ */
759
764
  function isBehaviourChange(change) {
760
765
  switch (change.kind) {
761
766
  case UnitChangeKind.Added:
762
767
  case UnitChangeKind.Removed: return true;
763
768
  case UnitChangeKind.Modified: return change.weight === ModificationWeight.Semantic;
769
+ case UnitChangeKind.MovedIn: return change.edited;
764
770
  case UnitChangeKind.Renamed:
765
- case UnitChangeKind.MovedIn:
766
771
  case UnitChangeKind.MovedOut: return false;
767
772
  }
768
773
  }
@@ -956,6 +961,21 @@ const ReviewEvent = {
956
961
  };
957
962
  const MAX_COMMENT_CHARS = 6e4;
958
963
  const lineSchema = z.number().int().positive();
964
+ const LineSide = {
965
+ Old: "old",
966
+ New: "new"
967
+ };
968
+ /** A line in the diff, by its number on each side; an unchanged line has both. */
969
+ const diffLineRefSchema = z.object({
970
+ oldLine: lineSchema.nullable(),
971
+ newLine: lineSchema.nullable()
972
+ });
973
+ /** Lines a reviewer chose, on one side of the diff, from `start` to `end`. */
974
+ const lineRangeSchema = z.object({
975
+ side: z.enum(LineSide),
976
+ start: diffLineRefSchema,
977
+ end: diffLineRefSchema
978
+ });
959
979
  const reviewCommentSchema = z.object({
960
980
  path: z.string().min(1),
961
981
  /** The file's previous path when it was renamed. GitLab needs both. */
@@ -964,6 +984,8 @@ const reviewCommentSchema = z.object({
964
984
  line: lineSchema.nullable(),
965
985
  /** What the comment is about, used when it can't sit on a line. */
966
986
  label: z.string(),
987
+ /** Lines the reviewer picked. Takes the place of `line` when set. */
988
+ range: lineRangeSchema.nullable().default(null),
967
989
  body: z.string().trim().min(1).max(MAX_COMMENT_CHARS)
968
990
  });
969
991
  /** What a reviewer submits. `headSha` is the commit they read, so a newer push can't be approved unseen. */
@@ -1017,6 +1039,18 @@ z.object({
1017
1039
  truncated: z.boolean()
1018
1040
  });
1019
1041
  z.object({ url: z.string() });
1042
+ /** Whether a comment can sit on lines of the diff; the others go in the review's text. */
1043
+ function isPlacedComment(comment) {
1044
+ return comment.range !== null || comment.line !== null;
1045
+ }
1046
+ /** Where a comment ends: the last line it covers, as a host addresses it. */
1047
+ function lastLineOf(comment) {
1048
+ if (comment.range !== null) return comment.range.end;
1049
+ return comment.line === null ? void 0 : {
1050
+ oldLine: null,
1051
+ newLine: comment.line
1052
+ };
1053
+ }
1020
1054
  // packages/engine/src/blobs.ts
1021
1055
  const NEWLINE = 10;
1022
1056
  /**
@@ -1633,7 +1667,7 @@ function toDefinition(spec, raw, lines) {
1633
1667
  text: outline(lines, startLine - 1, endLine - 1, raw.children),
1634
1668
  elidesNestedUnits: raw.children.length > 0
1635
1669
  },
1636
- codeTokenCount: code.length,
1670
+ codeTokens: code.map((token) => token.text),
1637
1671
  shape: raw.header.kind === UnitKind.Function || raw.header.kind === UnitKind.Method ? extractShape(spec.shape, raw.node) : void 0,
1638
1672
  fingerprints: {
1639
1673
  code: hashCode(code),
@@ -2495,8 +2529,8 @@ function searchedNameFor(unit) {
2495
2529
  case UnitChangeKind.Modified: return unit.change.weight === ModificationWeight.Semantic ? unit.name : void 0;
2496
2530
  case UnitChangeKind.Removed: return unit.name;
2497
2531
  case UnitChangeKind.Renamed: return unit.change.previousName;
2532
+ case UnitChangeKind.MovedIn: return unit.change.edited ? unit.name : void 0;
2498
2533
  case UnitChangeKind.Added:
2499
- case UnitChangeKind.MovedIn:
2500
2534
  case UnitChangeKind.MovedOut: return;
2501
2535
  }
2502
2536
  }
@@ -6365,6 +6399,32 @@ function coverageGaps(files, ignoredCount) {
6365
6399
  function byImportance(a, b) {
6366
6400
  return SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity] || Number(isSecurityFinding(b)) - Number(isSecurityFinding(a)) || (a.location?.path ?? "").localeCompare(b.location?.path ?? "") || (a.location?.line ?? 0) - (b.location?.line ?? 0);
6367
6401
  }
6402
+ // packages/engine/src/syntax/similarity.ts
6403
+ /**
6404
+ * How alike two token sequences are, from 0 (nothing shared) to 1 (the same).
6405
+ *
6406
+ * This is the Dice coefficient over adjacent token pairs. Pairs keep some of the order:
6407
+ * two functions that use the same keywords and names in a different arrangement score
6408
+ * lower than a function and its edited copy. Counting pairs as a multiset rather than
6409
+ * a set keeps a repeated line from looking as alike as the whole body.
6410
+ */
6411
+ function tokenSimilarity(a, b) {
6412
+ const pairsOfA = pairCounts(a);
6413
+ const pairsOfB = pairCounts(b);
6414
+ const total = a.length - 1 + (b.length - 1);
6415
+ if (total <= 0) return a.join("") === b.join("") ? 1 : 0;
6416
+ let shared = 0;
6417
+ for (const [pair, count] of pairsOfA) shared += Math.min(count, pairsOfB.get(pair) ?? 0);
6418
+ return 2 * shared / total;
6419
+ }
6420
+ function pairCounts(tokens) {
6421
+ const counts = /* @__PURE__ */ new Map();
6422
+ for (let index = 1; index < tokens.length; index++) {
6423
+ const pair = `${tokens[index - 1]}\0${tokens[index]}`;
6424
+ counts.set(pair, (counts.get(pair) ?? 0) + 1);
6425
+ }
6426
+ return counts;
6427
+ }
6368
6428
  // packages/engine/src/syntax/compareUnits.ts
6369
6429
  /**
6370
6430
  * Below this many code tokens, identical bodies are too common to call a move:
@@ -6372,13 +6432,33 @@ function byImportance(a, b) {
6372
6432
  */
6373
6433
  const MIN_MOVED_UNIT_TOKENS = 20;
6374
6434
  /**
6435
+ * How alike, by `tokenSimilarity`, a unit and a same-named one elsewhere must be to call
6436
+ * them one unit moved and edited. Measured on the cases in compareUnits.test.ts: a moved
6437
+ * function with one call changed scores about 0.93, while unrelated functions sharing a name
6438
+ * scored 0.24 to 0.45, and a rewrite of the same function 0.36. Lower, and different code
6439
+ * that shares a name would be shown as one edit; higher, and a moved function with a real
6440
+ * fix in it would be shown as removed and added again.
6441
+ */
6442
+ const MIN_EDITED_MOVE_SIMILARITY = .6;
6443
+ /**
6444
+ * Keywords that make a definition visible to other modules. Moving a function into a module
6445
+ * of its own usually means exporting it, so a move whose only change is one of these, before
6446
+ * the name, is shown as unedited: the new `export` isn't something to review.
6447
+ */
6448
+ const VISIBILITY_KEYWORDS = /* @__PURE__ */ new Set(["export", "pub"]);
6449
+ const RUST_VISIBILITY_GROUP_OPEN = "(";
6450
+ const RUST_VISIBILITY_GROUP_CLOSE = ")";
6451
+ /**
6375
6452
  * Compares unit versions across all files of a change. Outline:
6376
6453
  * 1. Per file, pair definitions by key; a pair whose own tokens differ is "modified".
6377
6454
  * 2. Unpaired definitions become added/removed candidates, topmost only (a new class
6378
6455
  * is reported once, not once per method).
6379
6456
  * 3. Across candidates, an added/removed pair with the same body under a new name in
6380
6457
  * the same container is a rename; the same body anywhere else is a move.
6381
- * 4. Remaining candidates are reported as added or removed.
6458
+ * 4. Of the rest, a pair of the same kind and name whose bodies are alike is a move with
6459
+ * edits. The most alike pairs are taken first, so three similar `parse`s can't steal
6460
+ * each other's match.
6461
+ * 5. Remaining candidates are reported as added or removed.
6382
6462
  */
6383
6463
  function compareUnits(files) {
6384
6464
  const unitsByPath = new Map(files.map((file) => [file.path, []]));
@@ -6410,25 +6490,8 @@ function compareUnits(files) {
6410
6490
  after: to.definition.snapshot
6411
6491
  }
6412
6492
  });
6413
- for (const [from, to] of takeMatches(removed, added, isMove)) {
6414
- report(from.path, {
6415
- ...describe(from.definition),
6416
- change: {
6417
- kind: UnitChangeKind.MovedOut,
6418
- to: locationOf(to),
6419
- before: from.definition.snapshot
6420
- }
6421
- });
6422
- report(to.path, {
6423
- ...describe(to.definition),
6424
- change: {
6425
- kind: UnitChangeKind.MovedIn,
6426
- from: locationOf(from),
6427
- before: from.definition.snapshot,
6428
- after: to.definition.snapshot
6429
- }
6430
- });
6431
- }
6493
+ for (const [from, to] of takeMatches(removed, added, isMove)) reportMove(report, from, to, MoveEdits.None);
6494
+ for (const [from, to] of takeMostAlike(removed, added)) reportMove(report, from, to, differsOnlyInVisibility(from.definition, to.definition) ? MoveEdits.None : MoveEdits.Code);
6432
6495
  for (const { path, definition } of added) report(path, {
6433
6496
  ...describe(definition),
6434
6497
  change: {
@@ -6446,6 +6509,35 @@ function compareUnits(files) {
6446
6509
  for (const units of unitsByPath.values()) units.sort(byPositionInFile);
6447
6510
  return unitsByPath;
6448
6511
  }
6512
+ const MoveEdits = {
6513
+ None: "none",
6514
+ Code: "code"
6515
+ };
6516
+ function reportMove(report, from, to, edits) {
6517
+ const edited = edits === MoveEdits.Code;
6518
+ const before = from.definition;
6519
+ const after = to.definition;
6520
+ report(from.path, {
6521
+ ...describe(before),
6522
+ change: {
6523
+ kind: UnitChangeKind.MovedOut,
6524
+ to: locationOf(to),
6525
+ edited,
6526
+ before: before.snapshot
6527
+ }
6528
+ });
6529
+ report(to.path, {
6530
+ ...describe(after),
6531
+ facts: edited && before.shape !== void 0 && after.shape !== void 0 ? factsBetween(before.shape, after.shape) : null,
6532
+ change: {
6533
+ kind: UnitChangeKind.MovedIn,
6534
+ from: locationOf(from),
6535
+ edited,
6536
+ before: before.snapshot,
6537
+ after: after.snapshot
6538
+ }
6539
+ });
6540
+ }
6449
6541
  function pairDefinitions(file) {
6450
6542
  const before = keyed(file.before?.definitions ?? []);
6451
6543
  const after = keyed(file.after?.definitions ?? []);
@@ -6524,7 +6616,57 @@ function isRename(from, to) {
6524
6616
  return from.path === to.path && from.definition.kind === to.definition.kind && from.definition.parentKey === to.definition.parentKey && from.definition.name !== to.definition.name && from.definition.fingerprints.nameAgnosticCode === to.definition.fingerprints.nameAgnosticCode;
6525
6617
  }
6526
6618
  function isMove(from, to) {
6527
- return from.definition.kind === to.definition.kind && from.definition.codeTokenCount >= MIN_MOVED_UNIT_TOKENS && from.definition.fingerprints.code === to.definition.fingerprints.code;
6619
+ return from.definition.kind === to.definition.kind && from.definition.codeTokens.length >= MIN_MOVED_UNIT_TOKENS && from.definition.fingerprints.code === to.definition.fingerprints.code;
6620
+ }
6621
+ function isEditedMoveCandidate(from, to) {
6622
+ return from.definition.kind === to.definition.kind && from.definition.name === to.definition.name && from.definition.codeTokens.length >= MIN_MOVED_UNIT_TOKENS && to.definition.codeTokens.length >= MIN_MOVED_UNIT_TOKENS;
6623
+ }
6624
+ function differsOnlyInVisibility(before, after) {
6625
+ const left = withoutVisibility(before.codeTokens, before.name);
6626
+ const right = withoutVisibility(after.codeTokens, after.name);
6627
+ return left.length === right.length && left.every((token, index) => token === right[index]);
6628
+ }
6629
+ /** The tokens with visibility keywords before the definition's name left out. */
6630
+ function withoutVisibility(tokens, name) {
6631
+ const nameAt = tokens.indexOf(name);
6632
+ if (nameAt === -1) return tokens;
6633
+ const head = [];
6634
+ for (let index = 0; index < nameAt; index++) {
6635
+ const token = tokens[index] ?? "";
6636
+ if (!VISIBILITY_KEYWORDS.has(token)) {
6637
+ head.push(token);
6638
+ continue;
6639
+ }
6640
+ if (tokens[index + 1] === RUST_VISIBILITY_GROUP_OPEN) {
6641
+ const close = tokens.indexOf(RUST_VISIBILITY_GROUP_CLOSE, index + 1);
6642
+ if (close !== -1 && close < nameAt) index = close;
6643
+ }
6644
+ }
6645
+ return [...head, ...tokens.slice(nameAt)];
6646
+ }
6647
+ /** Pairs edited moves best match first, removing each matched pair from both arrays. */
6648
+ function takeMostAlike(froms, tos) {
6649
+ const scored = froms.flatMap((from) => tos.filter((to) => isEditedMoveCandidate(from, to)).map((to) => ({
6650
+ from,
6651
+ to,
6652
+ similarity: tokenSimilarity(from.definition.codeTokens, to.definition.codeTokens)
6653
+ })).filter((pair) => pair.similarity >= MIN_EDITED_MOVE_SIMILARITY));
6654
+ scored.sort((a, b) => b.similarity - a.similarity);
6655
+ const taken = /* @__PURE__ */ new Set();
6656
+ const pairs = [];
6657
+ for (const { from, to } of scored) {
6658
+ if (taken.has(from) || taken.has(to)) continue;
6659
+ taken.add(from);
6660
+ taken.add(to);
6661
+ pairs.push([from, to]);
6662
+ }
6663
+ removeAll(froms, taken);
6664
+ removeAll(tos, taken);
6665
+ return pairs;
6666
+ }
6667
+ function removeAll(items, taken) {
6668
+ const kept = items.filter((item) => !taken.has(item));
6669
+ items.splice(0, items.length, ...kept);
6528
6670
  }
6529
6671
  /** Pairs elements of `froms` and `tos` one to one, removing each matched pair from both arrays. */
6530
6672
  function takeMatches(froms, tos, matches) {
@@ -7077,7 +7219,8 @@ function renderUnit(id, path, unit) {
7077
7219
  });
7078
7220
  };
7079
7221
  const { change } = unit;
7080
- if ("before" in change && change.kind !== UnitChangeKind.MovedIn) show("before", CitationSide.Before, change.before);
7222
+ const beforeAddsNothing = change.kind === UnitChangeKind.MovedIn && !change.edited;
7223
+ if ("before" in change && !beforeAddsNothing) show("before", CitationSide.Before, change.before);
7081
7224
  if ("after" in change) show("after", CitationSide.After, change.after);
7082
7225
  parts.push("</unit>");
7083
7226
  return {
@@ -7085,8 +7228,13 @@ function renderUnit(id, path, unit) {
7085
7228
  ranges
7086
7229
  };
7087
7230
  }
7231
+ function changeAttribute(change) {
7232
+ if (change.kind === UnitChangeKind.Modified) return `modified (${change.weight})`;
7233
+ if (change.kind === UnitChangeKind.MovedIn && change.edited) return `${change.kind} (edited)`;
7234
+ return change.kind;
7235
+ }
7088
7236
  function unitHeader(id, path, unit, summarized) {
7089
- const change = unit.change.kind === UnitChangeKind.Modified ? `modified (${unit.change.weight})` : unit.change.kind;
7237
+ const change = changeAttribute(unit.change);
7090
7238
  const impact = unit.impact?.status === UnitImpactStatus.Traced ? ` callers="${unit.impact.totalReferences}"` : "";
7091
7239
  const close = summarized ? ` summarized="input budget reached"/>` : ">";
7092
7240
  return `<unit id="${id}" path="${attribute(path)}" name="${attribute(unit.qualifiedName)}" kind="${unit.kind}" change="${change}"${impact}${close}`;
@@ -8398,7 +8546,7 @@ var GitHubHost = class {
8398
8546
  };
8399
8547
  }
8400
8548
  async submitReview(review) {
8401
- const onLines = review.comments.filter((comment) => comment.line !== null);
8549
+ const onLines = review.comments.filter(isPlacedComment);
8402
8550
  return { url: (await writeJson({
8403
8551
  method: "POST",
8404
8552
  url: `${this.#repoApi()}/pulls/${this.#ref.number}/reviews`,
@@ -8409,12 +8557,7 @@ var GitHubHost = class {
8409
8557
  commit_id: review.headSha,
8410
8558
  event: REVIEW_EVENTS[review.event],
8411
8559
  body: withUnplacedComments$1(review),
8412
- comments: onLines.map((comment) => ({
8413
- path: comment.path,
8414
- line: comment.line,
8415
- side: "RIGHT",
8416
- body: comment.body
8417
- }))
8560
+ comments: onLines.map(githubReviewComment)
8418
8561
  }
8419
8562
  })).html_url };
8420
8563
  }
@@ -8509,7 +8652,7 @@ const graphqlResponseSchema = z.object({
8509
8652
  const GRAPHQL_FAILURE_STATUS = 502;
8510
8653
  /** GitHub only accepts comments on lines, so anything without one joins the review's own text. */
8511
8654
  function withUnplacedComments$1(review) {
8512
- const unplaced = review.comments.filter((comment) => comment.line === null).map((comment) => `**\`${comment.label}\`** in \`${comment.path}\`\n\n${comment.body}`);
8655
+ const unplaced = review.comments.filter((comment) => !isPlacedComment(comment)).map((comment) => `**\`${comment.label}\`** in \`${comment.path}\`\n\n${comment.body}`);
8513
8656
  return [review.body, ...unplaced].filter((part) => part !== "").join("\n\n---\n\n");
8514
8657
  }
8515
8658
  function graphqlUrl(webOrigin) {
@@ -8518,6 +8661,29 @@ function graphqlUrl(webOrigin) {
8518
8661
  function apiBase(webOrigin) {
8519
8662
  return webOrigin === GITHUB_DOT_COM_ORIGIN$1 ? GITHUB_DOT_COM_API : `${webOrigin}/api/v3`;
8520
8663
  }
8664
+ function githubReviewComment(comment) {
8665
+ if (comment.range === null) return {
8666
+ path: comment.path,
8667
+ line: comment.line,
8668
+ side: "RIGHT",
8669
+ body: comment.body
8670
+ };
8671
+ const { side, start, end } = comment.range;
8672
+ const githubSide = side === LineSide.Old ? "LEFT" : "RIGHT";
8673
+ const number = (ref) => side === LineSide.Old ? ref.oldLine : ref.newLine;
8674
+ const startLine = number(start);
8675
+ const endLine = number(end);
8676
+ return {
8677
+ path: comment.path,
8678
+ line: endLine,
8679
+ side: githubSide,
8680
+ ...startLine !== endLine ? {
8681
+ start_line: startLine,
8682
+ start_side: githubSide
8683
+ } : {},
8684
+ body: comment.body
8685
+ };
8686
+ }
8521
8687
  // packages/providers/src/gitlab.ts
8522
8688
  const GITLAB_GIT_USERNAME = "oauth2";
8523
8689
  const AUTH_HINT = "Set GITLAB_TOKEN to a token with the read_api and read_repository scopes; posting comments needs the api scope.";
@@ -8667,18 +8833,22 @@ var GitLabHost = class {
8667
8833
  const mergeRequest = await this.#get(api, mergeRequestSchema);
8668
8834
  const refs = mergeRequest.diff_refs;
8669
8835
  if (refs === null) throw new DiffNotReadyError(mergeRequest.web_url);
8670
- for (const comment of review.comments.filter((candidate) => candidate.line !== null)) await this.#write("POST", `${api}/draft_notes`, {
8671
- note: comment.body,
8672
- position: {
8673
- position_type: "text",
8674
- base_sha: refs.base_sha,
8675
- start_sha: refs.start_sha,
8676
- head_sha: refs.head_sha,
8677
- old_path: comment.previousPath,
8678
- new_path: comment.path,
8679
- new_line: comment.line
8680
- }
8681
- });
8836
+ for (const comment of review.comments.filter(isPlacedComment)) {
8837
+ const last = lastLineOf(comment);
8838
+ await this.#write("POST", `${api}/draft_notes`, {
8839
+ note: gitlabNote(comment),
8840
+ position: {
8841
+ position_type: "text",
8842
+ base_sha: refs.base_sha,
8843
+ start_sha: refs.start_sha,
8844
+ head_sha: refs.head_sha,
8845
+ old_path: comment.previousPath,
8846
+ new_path: comment.path,
8847
+ ...last?.oldLine == null ? {} : { old_line: last.oldLine },
8848
+ ...last?.newLine == null ? {} : { new_line: last.newLine }
8849
+ }
8850
+ });
8851
+ }
8682
8852
  const text = withUnplacedComments(review);
8683
8853
  if (text !== "") await this.#write("POST", `${api}/draft_notes`, { note: text });
8684
8854
  const reviewerState = REVIEWER_PUBLISH_STATES[review.event];
@@ -8769,9 +8939,21 @@ var GitLabHost = class {
8769
8939
  };
8770
8940
  /** Comments without a line, and the summary, go together as one note. */
8771
8941
  function withUnplacedComments(review) {
8772
- const unplaced = review.comments.filter((comment) => comment.line === null).map((comment) => `**\`${comment.label}\`** in \`${comment.path}\`\n\n${comment.body}`);
8942
+ const unplaced = review.comments.filter((comment) => !isPlacedComment(comment)).map((comment) => `**\`${comment.label}\`** in \`${comment.path}\`\n\n${comment.body}`);
8773
8943
  return [review.body, ...unplaced].filter((part) => part !== "").join("\n\n---\n\n");
8774
8944
  }
8945
+ /**
8946
+ * GitLab's multi-line position needs line codes this can't check without a real instance, so a range
8947
+ * sits on its last line and says which lines it covers.
8948
+ */
8949
+ function gitlabNote(comment) {
8950
+ const range = comment.range;
8951
+ if (range === null) return comment.body;
8952
+ const number = (ref) => range.side === LineSide.Old ? ref.oldLine : ref.newLine;
8953
+ const first = number(range.start);
8954
+ const last = number(range.end);
8955
+ return first === last ? comment.body : `Lines ${first}–${last}${range.side === LineSide.Old ? " (before)" : ""}:\n\n${comment.body}`;
8956
+ }
8775
8957
  // packages/providers/src/trustedHosts.ts
8776
8958
  const TRUSTED_GITHUB_HOSTS_VARIABLE = "WALKDIFF_TRUSTED_GITHUB_HOSTS";
8777
8959
  const TRUSTED_GITLAB_HOSTS_VARIABLE = "WALKDIFF_TRUSTED_GITLAB_HOSTS";