@desplega.ai/wts 0.2.1 → 0.2.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/dist/index.js +37 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1877,7 +1877,7 @@ var {
|
|
|
1877
1877
|
// package.json
|
|
1878
1878
|
var package_default = {
|
|
1879
1879
|
name: "@desplega.ai/wts",
|
|
1880
|
-
version: "0.2.
|
|
1880
|
+
version: "0.2.2",
|
|
1881
1881
|
description: "Git worktree manager with tmux integration",
|
|
1882
1882
|
type: "module",
|
|
1883
1883
|
bin: {
|
|
@@ -3337,6 +3337,11 @@ function printWorktreeTable(worktrees, projectName) {
|
|
|
3337
3337
|
}
|
|
3338
3338
|
|
|
3339
3339
|
// src/commands/merge.ts
|
|
3340
|
+
async function getCommitsToMerge(branch, baseBranch, cwd) {
|
|
3341
|
+
const result = await Bun.$`git log ${baseBranch}..${branch} --oneline`.cwd(cwd).quiet();
|
|
3342
|
+
return result.stdout.toString().trim().split(`
|
|
3343
|
+
`).filter(Boolean);
|
|
3344
|
+
}
|
|
3340
3345
|
var mergeCommand = new Command2("merge").description("Merge a worktree branch into main").argument("[alias]", "Alias of the worktree to merge").option("--no-cleanup", "Skip cleanup prompt").option("--no-pull", "Skip pulling latest main").option("-f, --force", "Skip confirmations (except cleanup)").action(async (alias, options) => {
|
|
3341
3346
|
const gitRoot = await getGitRoot();
|
|
3342
3347
|
if (!gitRoot) {
|
|
@@ -3402,6 +3407,22 @@ Merging ${source_default.cyan(branchToMerge)} into ${source_default.cyan(default
|
|
|
3402
3407
|
await Bun.$`git pull`.cwd(mainPath);
|
|
3403
3408
|
}
|
|
3404
3409
|
}
|
|
3410
|
+
const commitsToMerge = await getCommitsToMerge(branchToMerge, defaultBranch, mainPath);
|
|
3411
|
+
if (commitsToMerge.length === 0) {
|
|
3412
|
+
console.log(source_default.yellow(`
|
|
3413
|
+
No commits to merge - ${branchToMerge} has no new commits compared to ${defaultBranch}`));
|
|
3414
|
+
console.log(source_default.dim("The branch may need to be rebased on latest main first."));
|
|
3415
|
+
console.log(source_default.dim("Aborting to prevent accidental data loss."));
|
|
3416
|
+
process.exit(1);
|
|
3417
|
+
}
|
|
3418
|
+
console.log(source_default.dim(`
|
|
3419
|
+
Commits to merge (${commitsToMerge.length}):`));
|
|
3420
|
+
for (const commit of commitsToMerge.slice(0, 5)) {
|
|
3421
|
+
console.log(source_default.dim(` ${commit}`));
|
|
3422
|
+
}
|
|
3423
|
+
if (commitsToMerge.length > 5) {
|
|
3424
|
+
console.log(source_default.dim(` ... and ${commitsToMerge.length - 5} more`));
|
|
3425
|
+
}
|
|
3405
3426
|
if (!options.force) {
|
|
3406
3427
|
const proceed = await confirm(`Merge ${branchToMerge}?`, true);
|
|
3407
3428
|
if (!proceed) {
|
|
@@ -3410,7 +3431,15 @@ Merging ${source_default.cyan(branchToMerge)} into ${source_default.cyan(default
|
|
|
3410
3431
|
}
|
|
3411
3432
|
}
|
|
3412
3433
|
console.log(source_default.dim(`Merging ${branchToMerge}...`));
|
|
3413
|
-
await Bun.$`git merge ${branchToMerge}`.cwd(mainPath);
|
|
3434
|
+
const mergeResult = await Bun.$`git merge ${branchToMerge}`.cwd(mainPath).quiet();
|
|
3435
|
+
const mergeOutput = mergeResult.stdout.toString();
|
|
3436
|
+
console.log(source_default.dim(mergeOutput.trim()));
|
|
3437
|
+
if (mergeOutput.includes("Already up to date")) {
|
|
3438
|
+
console.log(source_default.yellow(`
|
|
3439
|
+
Merge reported 'Already up to date' - no changes were made`));
|
|
3440
|
+
console.log(source_default.red("Aborting cleanup to prevent data loss"));
|
|
3441
|
+
process.exit(1);
|
|
3442
|
+
}
|
|
3414
3443
|
if (!options.force) {
|
|
3415
3444
|
const proceed = await confirm(`Push to origin?`, true);
|
|
3416
3445
|
if (!proceed) {
|
|
@@ -3432,7 +3461,12 @@ Clean up worktree and branch?`, false);
|
|
|
3432
3461
|
console.log(source_default.dim(`Removing worktree...`));
|
|
3433
3462
|
await removeWorktree(worktree.path, true, mainPath);
|
|
3434
3463
|
console.log(source_default.dim(`Deleting branch ${branchToMerge}...`));
|
|
3435
|
-
|
|
3464
|
+
try {
|
|
3465
|
+
await deleteBranch(branchToMerge, false, mainPath);
|
|
3466
|
+
} catch {
|
|
3467
|
+
console.error(source_default.red("Branch not fully merged - keeping branch for safety"));
|
|
3468
|
+
console.log(source_default.dim("Use 'git branch -D <branch>' to force delete if intended"));
|
|
3469
|
+
}
|
|
3436
3470
|
console.log(source_default.green(`✓ Cleaned up`));
|
|
3437
3471
|
}
|
|
3438
3472
|
}
|