reviewdeck 0.2.5 → 0.2.6

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.
@@ -477,6 +477,23 @@ function formatIndexedChanges(changes) {
477
477
  }
478
478
  return lines.join("\n");
479
479
  }
480
+ function collapseRanges(nums) {
481
+ if (nums.length === 0) return [];
482
+ const ranges = [];
483
+ let start = nums[0];
484
+ let end = start;
485
+ for (let i = 1; i < nums.length; i++) {
486
+ if (nums[i] === end + 1) {
487
+ end = nums[i];
488
+ } else {
489
+ ranges.push(start === end ? `${start}` : `${start}-${end}`);
490
+ start = nums[i];
491
+ end = start;
492
+ }
493
+ }
494
+ ranges.push(start === end ? `${start}` : `${start}-${end}`);
495
+ return ranges;
496
+ }
480
497
  function validateMeta(meta, totalChanges) {
481
498
  const errors = [];
482
499
  const assigned = /* @__PURE__ */ new Set();
@@ -492,15 +509,27 @@ function validateMeta(meta, totalChanges) {
492
509
  errors.push(`Group ${g + 1}: ${e.message}`);
493
510
  continue;
494
511
  }
512
+ const outOfRange = [];
513
+ const duplicates = [];
495
514
  for (const idx of expanded) {
496
515
  if (idx < 0 || idx >= totalChanges) {
497
- errors.push(`Group ${g + 1}: index ${idx} out of range [0, ${totalChanges - 1}]`);
516
+ outOfRange.push(idx);
498
517
  }
499
518
  if (assigned.has(idx)) {
500
- errors.push(`Group ${g + 1}: index ${idx} already assigned to another group`);
519
+ duplicates.push(idx);
501
520
  }
502
521
  assigned.add(idx);
503
522
  }
523
+ if (outOfRange.length > 0) {
524
+ for (const range of collapseRanges(outOfRange)) {
525
+ errors.push(`Group ${g + 1}: index ${range} out of range [0, ${totalChanges - 1}]`);
526
+ }
527
+ }
528
+ if (duplicates.length > 0) {
529
+ for (const range of collapseRanges(duplicates)) {
530
+ errors.push(`Group ${g + 1}: index ${range} already assigned to another group`);
531
+ }
532
+ }
504
533
  const groupChanges = new Set(expanded);
505
534
  for (let c = 0; c < (group.draftComments?.length ?? 0); c++) {
506
535
  const comment = group.draftComments[c];
@@ -520,9 +549,13 @@ function validateMeta(meta, totalChanges) {
520
549
  }
521
550
  }
522
551
  }
552
+ const unassigned = [];
523
553
  for (let i = 0; i < totalChanges; i++) {
524
- if (!assigned.has(i)) {
525
- errors.push(`Change ${i} is not assigned to any group`);
554
+ if (!assigned.has(i)) unassigned.push(i);
555
+ }
556
+ if (unassigned.length > 0) {
557
+ for (const range of collapseRanges(unassigned)) {
558
+ errors.push(`Change ${range} is not assigned to any group`);
526
559
  }
527
560
  }
528
561
  return errors;
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "reviewdeck",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Split large PR diffs into reviewable sub-patches via indexed groups.",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/neutree-ai/reviewdeck.git"
8
- },
9
5
  "homepage": "https://github.com/neutree-ai/reviewdeck",
10
6
  "bugs": {
11
7
  "url": "https://github.com/neutree-ai/reviewdeck/issues"
12
8
  },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/neutree-ai/reviewdeck.git"
12
+ },
13
13
  "bin": {
14
14
  "reviewdeck": "dist/reviewdeck.mjs"
15
15
  },