fix: canonicalize adopt session stores · Entire
fix: canonicalize adopt session stores
9cab96c→main·
peyton-alt·2w ago·2 files·+24 added/-1 removed
Sessions
0ed46044b4c8View transcript
[?
Session Adoption and Worktree Management FixesCodex·1 step](/content/gh/entireio/cli/session/019ef09e-1621-7183-8205-646a383a2faf#timeline-0ed46044b4c8/index.html)
Changes
2
cmd/entire/cli
Msession_adopt.go+5/-1
Msession_adopt_test.go+19
78 unmodified lines
79
80
81
82
82
83
84
85
462 unmodified lines
548
549
550
551
552
553
554
555
556
557
78 unmodified lines
if err != nil {
return fmt.Errorf("open current session store: %w", err)
}
sameSessionStore := sourceCommonDir == targetCommonDir
sameSessionStore := sameAdoptStore(sourceCommonDir, targetCommonDir)
if sameSessionStore && sameAdoptPath(sourceWorktree, targetWorktree) {
return errors.New("source and target are the same worktree; no session adoption is needed")
}
462 unmodified lines
return canonicalAdoptPath(a) == canonicalAdoptPath(b)
}
func sameAdoptStore(a, b string) bool {
return canonicalAdoptPath(a) == canonicalAdoptPath(b)
}
func canonicalAdoptPath(path string) string {
if path == "" {
return ""
Mcmd/entire/cli/session_adopt.go+5/-1
1269 unmodified lines
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1269 unmodified lines
}
}
func TestSameAdoptStoreCanonicalizesGitCommonDirSymlinks(t *testing.T) {
if runtime.GOOS == windowsGOOS {
t.Skip("symlink path canonicalization is POSIX-only in this test")
}
realCommonDir := filepath.Join(t.TempDir(), "real-common.git")
if err := os.MkdirAll(realCommonDir, 0o750); err != nil {
t.Fatal(err)
}
commonDirLink := filepath.Join(t.TempDir(), "common-link.git")
if err := os.Symlink(realCommonDir, commonDirLink); err != nil {
t.Skipf("symlinks unavailable: %v", err)
}
if !sameAdoptStore(commonDirLink, realCommonDir) {
t.Fatalf("sameAdoptStore(%q, %q) = false, want true", commonDirLink, realCommonDir)
}
}
func TestSessionAdopt_SameStoreReloadsSourceStateUnderLock(t *testing.T) {
sourceRepo := setupAdoptRepo(t)
targetWorktree := filepath.Join(t.TempDir(), "target-worktree")