episoda 0.2.38 → 0.2.40

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 CHANGED
@@ -1863,6 +1863,11 @@ var require_git_executor = __commonJS({
1863
1863
  { timeout: options?.timeout || 12e4 }
1864
1864
  // 2 minutes for clone
1865
1865
  );
1866
+ try {
1867
+ await execAsync(`git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"`, { cwd: command.path, timeout: 5e3 });
1868
+ } catch (configError) {
1869
+ console.error("[git-executor] EP1014: Failed to configure fetch refspec:", configError);
1870
+ }
1866
1871
  return {
1867
1872
  success: true,
1868
1873
  output: `Cloned bare repository to ${command.path}`,
@@ -3224,11 +3229,43 @@ var WorktreeManager = class _WorktreeManager {
3224
3229
  }
3225
3230
  try {
3226
3231
  const config = this.readConfig();
3227
- return config !== null;
3232
+ if (config === null) {
3233
+ return false;
3234
+ }
3235
+ await this.ensureFetchRefspecConfigured();
3236
+ return true;
3228
3237
  } catch {
3229
3238
  return false;
3230
3239
  }
3231
3240
  }
3241
+ /**
3242
+ * EP1014: Ensure fetch refspec is configured in bare repo
3243
+ * Older bare repos may be missing this configuration, causing stale worktrees
3244
+ */
3245
+ async ensureFetchRefspecConfigured() {
3246
+ try {
3247
+ const { execSync: execSync9 } = require("child_process");
3248
+ let fetchRefspec = null;
3249
+ try {
3250
+ fetchRefspec = execSync9("git config --get remote.origin.fetch", {
3251
+ cwd: this.bareRepoPath,
3252
+ encoding: "utf-8",
3253
+ timeout: 5e3
3254
+ }).trim();
3255
+ } catch {
3256
+ }
3257
+ if (!fetchRefspec) {
3258
+ console.log("[WorktreeManager] EP1014: Configuring missing fetch refspec for bare repo");
3259
+ execSync9('git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', {
3260
+ cwd: this.bareRepoPath,
3261
+ timeout: 5e3
3262
+ });
3263
+ console.log("[WorktreeManager] EP1014: Fetch refspec configured successfully");
3264
+ }
3265
+ } catch (error) {
3266
+ console.warn("[WorktreeManager] EP1014: Failed to configure fetch refspec:", error);
3267
+ }
3268
+ }
3232
3269
  /**
3233
3270
  * Create a new worktree project from scratch
3234
3271
  */
@@ -3285,7 +3322,8 @@ var WorktreeManager = class _WorktreeManager {
3285
3322
  }
3286
3323
  const fetchResult = await this.gitExecutor.execute({
3287
3324
  action: "fetch",
3288
- remote: "origin"
3325
+ remote: "origin",
3326
+ branch: "+refs/heads/main:refs/remotes/origin/main"
3289
3327
  }, { cwd: this.bareRepoPath });
3290
3328
  if (!fetchResult.success && createBranch) {
3291
3329
  console.error("[worktree-manager] Failed to fetch from origin:", fetchResult.output);