sync-worktrees 1.8.0 → 2.1.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.
Files changed (74) hide show
  1. package/README.md +4 -4
  2. package/dist/index.js +3324 -197
  3. package/dist/index.js.map +7 -1
  4. package/package.json +21 -11
  5. package/dist/constants.d.ts +0 -54
  6. package/dist/constants.d.ts.map +0 -1
  7. package/dist/constants.js +0 -66
  8. package/dist/constants.js.map +0 -1
  9. package/dist/errors/index.d.ts +0 -51
  10. package/dist/errors/index.d.ts.map +0 -1
  11. package/dist/errors/index.js +0 -119
  12. package/dist/errors/index.js.map +0 -1
  13. package/dist/index.d.ts +0 -3
  14. package/dist/index.d.ts.map +0 -1
  15. package/dist/services/config-loader.service.d.ts +0 -9
  16. package/dist/services/config-loader.service.d.ts.map +0 -1
  17. package/dist/services/config-loader.service.js +0 -193
  18. package/dist/services/config-loader.service.js.map +0 -1
  19. package/dist/services/git.service.d.ts +0 -51
  20. package/dist/services/git.service.d.ts.map +0 -1
  21. package/dist/services/git.service.js +0 -749
  22. package/dist/services/git.service.js.map +0 -1
  23. package/dist/services/path-resolution.service.d.ts +0 -7
  24. package/dist/services/path-resolution.service.d.ts.map +0 -1
  25. package/dist/services/path-resolution.service.js +0 -58
  26. package/dist/services/path-resolution.service.js.map +0 -1
  27. package/dist/services/worktree-metadata.service.d.ts +0 -22
  28. package/dist/services/worktree-metadata.service.d.ts.map +0 -1
  29. package/dist/services/worktree-metadata.service.js +0 -276
  30. package/dist/services/worktree-metadata.service.js.map +0 -1
  31. package/dist/services/worktree-status.service.d.ts +0 -28
  32. package/dist/services/worktree-status.service.d.ts.map +0 -1
  33. package/dist/services/worktree-status.service.js +0 -229
  34. package/dist/services/worktree-status.service.js.map +0 -1
  35. package/dist/services/worktree-sync.service.d.ts +0 -17
  36. package/dist/services/worktree-sync.service.d.ts.map +0 -1
  37. package/dist/services/worktree-sync.service.js +0 -454
  38. package/dist/services/worktree-sync.service.js.map +0 -1
  39. package/dist/types/index.d.ts +0 -32
  40. package/dist/types/index.d.ts.map +0 -1
  41. package/dist/types/index.js +0 -3
  42. package/dist/types/index.js.map +0 -1
  43. package/dist/types/sync-metadata.d.ts +0 -16
  44. package/dist/types/sync-metadata.d.ts.map +0 -1
  45. package/dist/types/sync-metadata.js +0 -3
  46. package/dist/types/sync-metadata.js.map +0 -1
  47. package/dist/utils/cli.d.ts +0 -14
  48. package/dist/utils/cli.d.ts.map +0 -1
  49. package/dist/utils/cli.js +0 -117
  50. package/dist/utils/cli.js.map +0 -1
  51. package/dist/utils/config-generator.d.ts +0 -4
  52. package/dist/utils/config-generator.d.ts.map +0 -1
  53. package/dist/utils/config-generator.js +0 -112
  54. package/dist/utils/config-generator.js.map +0 -1
  55. package/dist/utils/date-filter.d.ts +0 -10
  56. package/dist/utils/date-filter.d.ts.map +0 -1
  57. package/dist/utils/date-filter.js +0 -47
  58. package/dist/utils/date-filter.js.map +0 -1
  59. package/dist/utils/git-url.d.ts +0 -15
  60. package/dist/utils/git-url.d.ts.map +0 -1
  61. package/dist/utils/git-url.js +0 -46
  62. package/dist/utils/git-url.js.map +0 -1
  63. package/dist/utils/interactive.d.ts +0 -3
  64. package/dist/utils/interactive.d.ts.map +0 -1
  65. package/dist/utils/interactive.js +0 -195
  66. package/dist/utils/interactive.js.map +0 -1
  67. package/dist/utils/lfs-error.d.ts +0 -23
  68. package/dist/utils/lfs-error.d.ts.map +0 -1
  69. package/dist/utils/lfs-error.js +0 -45
  70. package/dist/utils/lfs-error.js.map +0 -1
  71. package/dist/utils/retry.d.ts +0 -15
  72. package/dist/utils/retry.d.ts.map +0 -1
  73. package/dist/utils/retry.js +0 -78
  74. package/dist/utils/retry.js.map +0 -1
@@ -1,454 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.WorktreeSyncService = void 0;
37
- const fs = __importStar(require("fs/promises"));
38
- const path = __importStar(require("path"));
39
- const date_filter_1 = require("../utils/date-filter");
40
- const lfs_error_1 = require("../utils/lfs-error");
41
- const retry_1 = require("../utils/retry");
42
- const git_service_1 = require("./git.service");
43
- class WorktreeSyncService {
44
- config;
45
- gitService;
46
- constructor(config) {
47
- this.config = config;
48
- this.gitService = new git_service_1.GitService(config);
49
- }
50
- async initialize() {
51
- await this.gitService.initialize();
52
- }
53
- async sync() {
54
- console.log(`[${new Date().toISOString()}] Starting worktree synchronization...`);
55
- let lfsSkipEnabled = false;
56
- const retryOptions = {
57
- maxAttempts: this.config.retry?.maxAttempts ?? 3,
58
- maxLfsRetries: this.config.retry?.maxLfsRetries ?? 2,
59
- initialDelayMs: this.config.retry?.initialDelayMs ?? 1000,
60
- maxDelayMs: this.config.retry?.maxDelayMs ?? 30000,
61
- backoffMultiplier: this.config.retry?.backoffMultiplier ?? 2,
62
- onRetry: (error, attempt, context) => {
63
- const errorMessage = (0, lfs_error_1.getErrorMessage)(error);
64
- console.log(`\n⚠️ Sync attempt ${attempt} failed: ${errorMessage}`);
65
- if (context?.isLfsError && !this.config.skipLfs) {
66
- console.log(`🔄 LFS error detected. Will retry with LFS skipped...`);
67
- }
68
- else {
69
- console.log(`🔄 Retrying synchronization...\n`);
70
- }
71
- },
72
- lfsRetryHandler: () => {
73
- if (!this.config.skipLfs && !lfsSkipEnabled) {
74
- console.log("⚠️ Temporarily disabling LFS downloads for this sync...");
75
- process.env.GIT_LFS_SKIP_SMUDGE = "1";
76
- lfsSkipEnabled = true;
77
- }
78
- },
79
- };
80
- try {
81
- await (0, retry_1.retry)(async () => {
82
- await this.gitService.pruneWorktrees();
83
- console.log("Step 1: Fetching latest data from remote...");
84
- try {
85
- await this.gitService.fetchAll();
86
- }
87
- catch (fetchError) {
88
- const errorMessage = (0, lfs_error_1.getErrorMessage)(fetchError);
89
- if ((0, lfs_error_1.isLfsError)(errorMessage) && !lfsSkipEnabled && !this.config.skipLfs) {
90
- console.log("⚠️ Fetch all failed due to LFS error. Attempting branch-by-branch fetch...");
91
- console.log("⚠️ Temporarily disabling LFS downloads for branch-by-branch fetch...");
92
- process.env.GIT_LFS_SKIP_SMUDGE = "1";
93
- lfsSkipEnabled = true;
94
- await this.fetchBranchByBranch();
95
- }
96
- else {
97
- throw fetchError;
98
- }
99
- }
100
- let remoteBranches;
101
- if (this.config.branchMaxAge) {
102
- const branchesWithActivity = await this.gitService.getRemoteBranchesWithActivity();
103
- const filteredBranches = (0, date_filter_1.filterBranchesByAge)(branchesWithActivity, this.config.branchMaxAge);
104
- remoteBranches = filteredBranches.map((b) => b.branch);
105
- console.log(`Found ${branchesWithActivity.length} remote branches.`);
106
- console.log(`After filtering by age (${(0, date_filter_1.formatDuration)(this.config.branchMaxAge)}): ${remoteBranches.length} branches.`);
107
- if (branchesWithActivity.length > remoteBranches.length) {
108
- const excludedCount = branchesWithActivity.length - remoteBranches.length;
109
- console.log(` - Excluded ${excludedCount} stale branches.`);
110
- }
111
- }
112
- else {
113
- // Use original method if no age filtering
114
- remoteBranches = await this.gitService.getRemoteBranches();
115
- console.log(`Found ${remoteBranches.length} remote branches.`);
116
- }
117
- // Always retain the default branch, even if excluded by age filters
118
- const defaultBranch = this.gitService.getDefaultBranch();
119
- if (!remoteBranches.includes(defaultBranch)) {
120
- remoteBranches.push(defaultBranch);
121
- console.log(`Ensuring default branch '${defaultBranch}' is retained.`);
122
- }
123
- await fs.mkdir(this.config.worktreeDir, { recursive: true });
124
- // Get actual Git worktrees instead of just directories
125
- const worktrees = await this.gitService.getWorktrees();
126
- const worktreeBranches = worktrees.map((w) => w.branch);
127
- console.log(`Found ${worktrees.length} existing Git worktrees.`);
128
- // Clean up orphaned directories
129
- await this.cleanupOrphanedDirectories(worktrees);
130
- await this.createNewWorktrees(remoteBranches, worktreeBranches, defaultBranch);
131
- await this.pruneOldWorktrees(remoteBranches, worktreeBranches);
132
- // Update existing worktrees if enabled
133
- if (this.config.updateExistingWorktrees !== false) {
134
- await this.updateExistingWorktrees(worktrees, remoteBranches);
135
- }
136
- await this.gitService.pruneWorktrees();
137
- console.log("Step 5: Pruned worktree metadata.");
138
- }, retryOptions);
139
- }
140
- catch (error) {
141
- console.error("\n❌ Error during worktree synchronization after all retry attempts:", error);
142
- throw error;
143
- }
144
- finally {
145
- // Clean up temporary LFS skip if it was enabled
146
- if (lfsSkipEnabled && !this.config.skipLfs) {
147
- delete process.env.GIT_LFS_SKIP_SMUDGE;
148
- }
149
- console.log(`[${new Date().toISOString()}] Synchronization finished.\n`);
150
- }
151
- }
152
- async createNewWorktrees(remoteBranches, existingWorktreeBranches, defaultBranch) {
153
- const newBranches = remoteBranches
154
- .filter((b) => !existingWorktreeBranches.includes(b))
155
- .filter((b) => b !== defaultBranch);
156
- if (newBranches.length > 0) {
157
- console.log(`Step 2: Creating new worktrees for: ${newBranches.join(", ")}`);
158
- for (const branchName of newBranches) {
159
- const worktreePath = path.join(this.config.worktreeDir, branchName);
160
- await this.gitService.addWorktree(branchName, worktreePath);
161
- }
162
- }
163
- else {
164
- console.log("Step 2: No new branches to create worktrees for.");
165
- }
166
- }
167
- async pruneOldWorktrees(remoteBranches, existingWorktreeBranches) {
168
- const deletedBranches = existingWorktreeBranches.filter((branch) => !remoteBranches.includes(branch));
169
- if (deletedBranches.length > 0) {
170
- console.log(`Step 3: Checking for stale worktrees to prune: ${deletedBranches.join(", ")}`);
171
- for (const branchName of deletedBranches) {
172
- const worktreePath = path.join(this.config.worktreeDir, branchName);
173
- try {
174
- const isClean = await this.gitService.checkWorktreeStatus(worktreePath);
175
- const hasUnpushed = await this.gitService.hasUnpushedCommits(worktreePath);
176
- const hasStash = await this.gitService.hasStashedChanges(worktreePath);
177
- const hasOperation = await this.gitService.hasOperationInProgress(worktreePath);
178
- const hasDirtySubmodules = await this.gitService.hasModifiedSubmodules(worktreePath);
179
- const canDelete = isClean && !hasUnpushed && !hasStash && !hasOperation && !hasDirtySubmodules;
180
- if (canDelete) {
181
- await this.gitService.removeWorktree(worktreePath);
182
- }
183
- else {
184
- // Check if upstream is gone for better messaging
185
- const upstreamGone = hasUnpushed && (await this.gitService.hasUpstreamGone(worktreePath));
186
- if (upstreamGone) {
187
- console.warn(` - ⚠️ Cannot automatically remove '${branchName}' - upstream branch was deleted.`);
188
- console.log(` Please review manually: cd ${worktreePath} && git log`);
189
- console.log(` If changes were squash-merged, you can safely remove with: git worktree remove ${worktreePath}`);
190
- }
191
- else {
192
- // Log specific reasons for skipping
193
- const reasons = [];
194
- if (!isClean)
195
- reasons.push("uncommitted changes");
196
- if (hasUnpushed)
197
- reasons.push("unpushed commits");
198
- if (hasStash)
199
- reasons.push("stashed changes");
200
- if (hasOperation)
201
- reasons.push("operation in progress");
202
- if (hasDirtySubmodules)
203
- reasons.push("modified submodules");
204
- console.log(` - ⚠️ Skipping removal of '${branchName}' due to: ${reasons.join(", ")}.`);
205
- }
206
- }
207
- }
208
- catch (error) {
209
- console.error(` - Error checking worktree '${branchName}':`, error);
210
- }
211
- }
212
- }
213
- else {
214
- console.log("Step 3: No stale worktrees to prune.");
215
- }
216
- }
217
- async fetchBranchByBranch() {
218
- console.log("Fetching branches individually to isolate LFS errors...");
219
- // First, get the list of remote branches (this shouldn't fail due to LFS)
220
- const remoteBranches = await this.gitService.getRemoteBranches();
221
- console.log(`Found ${remoteBranches.length} remote branches to fetch.`);
222
- const failedBranches = [];
223
- let successCount = 0;
224
- for (const branch of remoteBranches) {
225
- try {
226
- await this.gitService.fetchBranch(branch);
227
- successCount++;
228
- }
229
- catch (error) {
230
- const errorMessage = (0, lfs_error_1.getErrorMessage)(error);
231
- console.log(` ⚠️ Failed to fetch branch '${branch}': ${errorMessage}`);
232
- failedBranches.push(branch);
233
- }
234
- }
235
- console.log(`Branch-by-branch fetch completed: ${successCount}/${remoteBranches.length} successful`);
236
- if (failedBranches.length > 0) {
237
- console.log(`⚠️ Failed to fetch ${failedBranches.length} branches due to errors.`);
238
- console.log(` These branches will be skipped: ${failedBranches.join(", ")}`);
239
- }
240
- }
241
- async updateExistingWorktrees(worktrees, remoteBranches) {
242
- const worktreesToUpdate = [];
243
- console.log("Step 4: Checking for worktrees that need updates...");
244
- // Check for diverged worktrees
245
- const divergedDir = path.join(this.config.worktreeDir, ".diverged");
246
- try {
247
- const diverged = await fs.readdir(divergedDir);
248
- if (diverged.length > 0) {
249
- console.log(`📦 Note: ${diverged.length} diverged worktree(s) in ${path.relative(process.cwd(), divergedDir)}`);
250
- }
251
- }
252
- catch {
253
- // No diverged directory, that's fine
254
- }
255
- // Only check worktrees whose branches still exist remotely
256
- const activeWorktrees = worktrees.filter((w) => remoteBranches.includes(w.branch));
257
- // Check each active worktree to see if it's behind and clean
258
- for (const worktree of activeWorktrees) {
259
- try {
260
- // First check if the worktree directory actually exists
261
- try {
262
- await fs.access(worktree.path);
263
- }
264
- catch {
265
- // Directory doesn't exist, skip it
266
- continue;
267
- }
268
- // Skip if an operation is in progress (merge/rebase/etc.)
269
- const hasOp = await this.gitService.hasOperationInProgress(worktree.path);
270
- if (hasOp) {
271
- continue;
272
- }
273
- const isClean = await this.gitService.checkWorktreeStatus(worktree.path);
274
- if (!isClean) {
275
- continue; // Skip worktrees with local changes
276
- }
277
- // Check if we can fast-forward before attempting update
278
- const canFastForward = await this.gitService.canFastForward(worktree.path, worktree.branch);
279
- if (!canFastForward) {
280
- // Handle diverged branch
281
- await this.handleDivergedBranch(worktree);
282
- continue;
283
- }
284
- const isBehind = await this.gitService.isWorktreeBehind(worktree.path);
285
- if (isBehind) {
286
- worktreesToUpdate.push(worktree);
287
- }
288
- }
289
- catch (error) {
290
- console.error(` - Error checking worktree '${worktree.branch}':`, error);
291
- }
292
- }
293
- if (worktreesToUpdate.length > 0) {
294
- console.log(` - Found ${worktreesToUpdate.length} worktrees behind their upstream branches.`);
295
- for (const worktree of worktreesToUpdate) {
296
- try {
297
- console.log(` - Updating worktree '${worktree.branch}'...`);
298
- await this.gitService.updateWorktree(worktree.path);
299
- console.log(` ✅ Successfully updated '${worktree.branch}'.`);
300
- }
301
- catch (error) {
302
- // Check if this is specifically a fast-forward error indicating diverged history
303
- const errorMessage = (0, lfs_error_1.getErrorMessage)(error);
304
- // Only treat as diverged if it's specifically a fast-forward failure
305
- // Other errors (network issues, permission problems, etc.) should not trigger divergence handling
306
- if (errorMessage.includes("Not possible to fast-forward") ||
307
- errorMessage.includes("fatal: Not possible to fast-forward, aborting") ||
308
- errorMessage.includes("cannot fast-forward")) {
309
- console.log(` ⚠️ Branch '${worktree.branch}' cannot be fast-forwarded. Checking for divergence...`);
310
- try {
311
- await this.handleDivergedBranch(worktree);
312
- }
313
- catch (divergedError) {
314
- console.error(` ❌ Failed to handle diverged branch '${worktree.branch}':`, divergedError);
315
- }
316
- }
317
- else {
318
- // Other errors: network issues, permission problems, disk space, etc.
319
- console.error(` ❌ Failed to update '${worktree.branch}':`, error);
320
- }
321
- }
322
- }
323
- }
324
- else {
325
- console.log(" - All worktrees are up to date.");
326
- }
327
- }
328
- async cleanupOrphanedDirectories(worktrees) {
329
- try {
330
- const worktreeRelativePaths = worktrees.map((w) => path.relative(this.config.worktreeDir, w.path));
331
- const allDirs = await fs.readdir(this.config.worktreeDir);
332
- // Filter out special directories like .diverged
333
- const regularDirs = allDirs.filter((dir) => !dir.startsWith("."));
334
- // For each directory, check if it's part of any worktree path
335
- const orphanedDirs = [];
336
- for (const dir of regularDirs) {
337
- // Check if this directory is part of any worktree path
338
- const isPartOfWorktree = worktreeRelativePaths.some((worktreePath) => {
339
- // Either the directory IS a worktree or it's a parent of a worktree
340
- return worktreePath === dir || worktreePath.startsWith(dir + path.sep);
341
- });
342
- if (!isPartOfWorktree) {
343
- orphanedDirs.push(dir);
344
- }
345
- }
346
- if (orphanedDirs.length > 0) {
347
- console.log(`Found ${orphanedDirs.length} orphaned directories: ${orphanedDirs.join(", ")}`);
348
- for (const dir of orphanedDirs) {
349
- const dirPath = path.join(this.config.worktreeDir, dir);
350
- try {
351
- const stat = await fs.stat(dirPath);
352
- if (stat.isDirectory()) {
353
- await fs.rm(dirPath, { recursive: true, force: true });
354
- console.log(` - Removed orphaned directory: ${dir}`);
355
- }
356
- }
357
- catch (error) {
358
- console.error(` - Failed to remove orphaned directory ${dir}:`, error);
359
- }
360
- }
361
- }
362
- }
363
- catch (error) {
364
- console.error("Error during orphaned directory cleanup:", error);
365
- }
366
- }
367
- async handleDivergedBranch(worktree) {
368
- console.log(`⚠️ Branch '${worktree.branch}' has diverged from upstream. Analyzing...`);
369
- const treesIdentical = await this.gitService.compareTreeContent(worktree.path, worktree.branch);
370
- if (treesIdentical) {
371
- console.log(`✅ Branch '${worktree.branch}' was rebased but files are identical. Resetting to upstream...`);
372
- await this.gitService.resetToUpstream(worktree.path, worktree.branch);
373
- console.log(` Successfully updated '${worktree.branch}' to match upstream.`);
374
- }
375
- else {
376
- const hasLocalChanges = await this.hasLocalChangesSinceLastSync(worktree.path);
377
- if (!hasLocalChanges) {
378
- console.log(`✅ Branch '${worktree.branch}' has diverged but you made no local changes. Resetting to upstream...`);
379
- await this.gitService.resetToUpstream(worktree.path, worktree.branch);
380
- console.log(` Successfully updated '${worktree.branch}' to match upstream.`);
381
- }
382
- else {
383
- console.log(`🔒 Branch '${worktree.branch}' has diverged with local changes. Moving to diverged...`);
384
- const divergedPath = await this.divergeWorktree(worktree.path, worktree.branch);
385
- const relativePath = path.relative(process.cwd(), divergedPath);
386
- console.log(` Moved to: ${relativePath}`);
387
- console.log(` Your local changes are preserved. To review:`);
388
- console.log(` cd ${relativePath}`);
389
- console.log(` git diff origin/${worktree.branch}`);
390
- await this.gitService.removeWorktree(worktree.path);
391
- await this.gitService.addWorktree(worktree.branch, worktree.path);
392
- console.log(` Created fresh worktree from upstream at: ${worktree.path}`);
393
- }
394
- }
395
- }
396
- async hasLocalChangesSinceLastSync(worktreePath) {
397
- try {
398
- const metadata = await this.gitService.getWorktreeMetadata(worktreePath);
399
- if (!metadata || !metadata.lastSyncCommit) {
400
- return true;
401
- }
402
- const currentCommit = await this.gitService.getCurrentCommit(worktreePath);
403
- return currentCommit !== metadata.lastSyncCommit;
404
- }
405
- catch {
406
- return true;
407
- }
408
- }
409
- async divergeWorktree(worktreePath, branchName) {
410
- // Create .diverged directory inside worktreeDir
411
- const divergedBaseDir = path.join(this.config.worktreeDir, ".diverged");
412
- const timestamp = new Date().toISOString().split("T")[0];
413
- const uniqueSuffix = Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
414
- const safeBranchName = branchName.replace(/\//g, "-");
415
- const divergedName = `${timestamp}-${safeBranchName}-${uniqueSuffix}`;
416
- const divergedPath = path.join(divergedBaseDir, divergedName);
417
- // Ensure diverged directory exists
418
- await fs.mkdir(divergedBaseDir, { recursive: true });
419
- // Move the worktree directory; on cross-device errors, fall back to copy+remove
420
- try {
421
- await fs.rename(worktreePath, divergedPath);
422
- }
423
- catch (err) {
424
- const msg = err instanceof Error ? err.message : String(err);
425
- if (msg.includes("EXDEV")) {
426
- // Cross-device link not permitted: copy then remove
427
- await fs.cp(worktreePath, divergedPath, { recursive: true });
428
- await fs.rm(worktreePath, { recursive: true, force: true });
429
- }
430
- else {
431
- throw err;
432
- }
433
- }
434
- // Save metadata about why it was moved
435
- const metadata = {
436
- originalBranch: branchName,
437
- divergedAt: new Date().toISOString(),
438
- reason: "diverged-history-with-changes",
439
- originalPath: worktreePath,
440
- localCommit: await this.gitService.getCurrentCommit(divergedPath),
441
- remoteCommit: await this.gitService.getRemoteCommit(`origin/${branchName}`),
442
- instruction: `To preserve your changes:
443
- 1. Review: git diff origin/${branchName}
444
- 2. Keep changes: git push --force-with-lease origin ${branchName}
445
- 3. Discard changes: rm -rf this directory
446
-
447
- Original worktree location: ${worktreePath}`,
448
- };
449
- await fs.writeFile(path.join(divergedPath, ".diverged-info.json"), JSON.stringify(metadata, null, 2));
450
- return divergedPath;
451
- }
452
- }
453
- exports.WorktreeSyncService = WorktreeSyncService;
454
- //# sourceMappingURL=worktree-sync.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worktree-sync.service.js","sourceRoot":"","sources":["../../src/services/worktree-sync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAE7B,sDAA2E;AAC3E,kDAAiE;AACjE,0CAAuC;AAEvC,+CAA2C;AAK3C,MAAa,mBAAmB;IAGV;IAFZ,UAAU,CAAa;IAE/B,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,wBAAU,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,GA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
3
- maxLfsRetries?: number;
4
- initialDelayMs?: number;
5
- maxDelayMs?: number;
6
- backoffMultiplier?: number;
7
- }
8
- export interface Config {
9
- repoUrl: string;
10
- worktreeDir: string;
11
- cronSchedule: string;
12
- runOnce: boolean;
13
- bareRepoDir?: string;
14
- retry?: RetryConfig;
15
- branchMaxAge?: string;
16
- skipLfs?: boolean;
17
- updateExistingWorktrees?: boolean;
18
- }
19
- export interface RepositoryConfig extends Config {
20
- name: string;
21
- }
22
- export interface ConfigFile {
23
- defaults?: Partial<Config>;
24
- repositories: RepositoryConfig[];
25
- retry?: RetryConfig;
26
- }
27
- export interface WorktreeStatus {
28
- branchName: string;
29
- worktreePath: string;
30
- hasLocalChanges: boolean;
31
- }
32
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,gBAAiB,SAAQ,MAAM;IAC9C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3B,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;CAC1B"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
@@ -1,16 +0,0 @@
1
- export interface SyncMetadata {
2
- lastSyncCommit: string;
3
- lastSyncDate: string;
4
- upstreamBranch: string;
5
- createdFrom: {
6
- branch: string;
7
- commit: string;
8
- };
9
- syncHistory: SyncHistoryEntry[];
10
- }
11
- export interface SyncHistoryEntry {
12
- date: string;
13
- commit: string;
14
- action: "created" | "updated" | "fetched";
15
- }
16
- //# sourceMappingURL=sync-metadata.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-metadata.d.ts","sourceRoot":"","sources":["../../src/types/sync-metadata.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,WAAW,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;CAC3C"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=sync-metadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-metadata.js","sourceRoot":"","sources":["../../src/types/sync-metadata.ts"],"names":[],"mappings":""}
@@ -1,14 +0,0 @@
1
- import type { Config } from "../types";
2
- export interface CliOptions extends Partial<Config> {
3
- config?: string;
4
- filter?: string;
5
- list?: boolean;
6
- bareRepoDir?: string;
7
- branchMaxAge?: string;
8
- skipLfs?: boolean;
9
- noUpdateExisting?: boolean;
10
- }
11
- export declare function parseArguments(): CliOptions;
12
- export declare function isInteractiveMode(config: Partial<Config>): boolean;
13
- export declare function reconstructCliCommand(config: Config): string;
14
- //# sourceMappingURL=cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,UAAW,SAAQ,OAAO,CAAC,MAAM,CAAC;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,wBAAgB,cAAc,IAAI,UAAU,CA4E3C;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAElE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAoC5D"}