@wipcomputer/wip-release 1.9.44 → 1.9.46
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/core.mjs +33 -0
- package/package.json +1 -1
package/core.mjs
CHANGED
|
@@ -1579,6 +1579,39 @@ export async function release({ repoPath, level, notes, notesSource, dryRun, noP
|
|
|
1579
1579
|
console.log(` ! Branch prune skipped: ${e.message}`);
|
|
1580
1580
|
}
|
|
1581
1581
|
|
|
1582
|
+
// 12. Prune stale worktrees (#212)
|
|
1583
|
+
try {
|
|
1584
|
+
execSync('git worktree prune', { cwd: repoPath, stdio: 'pipe' });
|
|
1585
|
+
// Also check _worktrees/ for dirs whose branches are now merged
|
|
1586
|
+
const worktreesDir = join(dirname(repoPath), '_worktrees');
|
|
1587
|
+
if (existsSync(worktreesDir)) {
|
|
1588
|
+
const repoBase = basename(repoPath);
|
|
1589
|
+
const wtDirs = readdirSync(worktreesDir, { withFileTypes: true })
|
|
1590
|
+
.filter(d => d.isDirectory() && d.name.startsWith(repoBase + '--'));
|
|
1591
|
+
let wtPruned = 0;
|
|
1592
|
+
for (const d of wtDirs) {
|
|
1593
|
+
const wtPath = join(worktreesDir, d.name);
|
|
1594
|
+
try {
|
|
1595
|
+
// Check if branch is merged into main
|
|
1596
|
+
const branch = execSync('git branch --show-current', {
|
|
1597
|
+
cwd: wtPath, encoding: 'utf8', timeout: 3000
|
|
1598
|
+
}).trim();
|
|
1599
|
+
if (branch) {
|
|
1600
|
+
execSync(`git merge-base --is-ancestor "${branch}" main`, {
|
|
1601
|
+
cwd: repoPath, stdio: 'pipe', timeout: 5000
|
|
1602
|
+
});
|
|
1603
|
+
// Branch is merged. Remove worktree.
|
|
1604
|
+
execSync(`git worktree remove "${wtPath}"`, { cwd: repoPath, stdio: 'pipe' });
|
|
1605
|
+
wtPruned++;
|
|
1606
|
+
}
|
|
1607
|
+
} catch {} // Branch not merged or other issue, leave it
|
|
1608
|
+
}
|
|
1609
|
+
if (wtPruned > 0) {
|
|
1610
|
+
console.log(` ✓ Pruned ${wtPruned} merged worktree(s) from _worktrees/`);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
} catch {}
|
|
1614
|
+
|
|
1582
1615
|
// Write release marker so branch guard blocks immediate install (#73)
|
|
1583
1616
|
try {
|
|
1584
1617
|
const markerDir = join(process.env.HOME || '', '.ldm', 'state');
|
package/package.json
CHANGED