| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cc68afb commit 9b7b6cb
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -361,13 +361,15 @@ export const layer: Layer.Layer< | |||
| 361 | 361 | } | |
| 362 | 362 | ||
| 363 | 363 | const primary = yield* canonical(ctx.worktree) | |
| 364 | + const primaryName = pathSvc.basename(primary).toLowerCase() | ||
| 364 | 365 | return yield* Effect.forEach(parseWorktreeList(result.text), (entry) => | |
| 365 | 366 | Effect.gen(function* () { | |
| 366 | 367 | if (!entry.path) return undefined | |
| 367 | 368 | const directory = yield* canonical(entry.path) | |
| 368 | 369 | if (directory === primary) return undefined | |
| 370 | + const name = pathSvc.basename(directory).toLowerCase() | ||
| 369 | 371 | return { | |
| 370 | - name: pathSvc.basename(directory), | ||
| 372 | + name: name === primaryName ? pathSvc.basename(pathSvc.dirname(directory)) : name, | ||
| 371 | 373 | directory, | |
| 372 | 374 | ...(entry.branch ? { branch: entry.branch.replace(/^refs\/heads\//, "") } : {}), | |
| 373 | 375 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -200,6 +200,35 @@ describe("Worktree", () => { | |||
| 200 | 200 | ) | |
| 201 | 201 | }) | |
| 202 | 202 | ||
| 203 | + describe("list", () => { | ||
| 204 | + it.live("uses parent folder name when worktree basename matches the primary worktree", () => | ||
| 205 | + provideTmpdirInstance( | ||
| 206 | + (dir) => | ||
| 207 | + Effect.gen(function* () { | ||
| 208 | + const svc = yield* Worktree.Service | ||
| 209 | + const parent = path.join(path.dirname(dir), `${path.basename(dir)}-parent`) | ||
| 210 | + const target = path.join(parent, path.basename(dir)) | ||
| 211 | + const branch = `same-basename-list-${Date.now()}` | ||
| 212 | + | ||
| 213 | + yield* Effect.promise(() => fs.mkdir(parent, { recursive: true })) | ||
| 214 | + yield* Effect.promise(() => $`git worktree add -b ${branch} ${target}`.cwd(dir).quiet()) | ||
| 215 | + | ||
| 216 | + const list = yield* svc.list() | ||
| 217 | + const directory = yield* Effect.promise(() => fs.realpath(target).catch(() => target)) | ||
| 218 | + | ||
| 219 | + expect(list).toContainEqual({ | ||
| 220 | + name: path.basename(parent), | ||
| 221 | + branch, | ||
| 222 | + directory: directory.toLowerCase(), | ||
| 223 | + }) | ||
| 224 | + | ||
| 225 | + yield* svc.remove({ directory: target }) | ||
| 226 | + }), | ||
| 227 | + { git: true }, | ||
| 228 | + ), | ||
| 229 | + ) | ||
| 230 | + }) | ||
| 231 | + | ||
| 203 | 232 | describe("remove edge cases", () => { | |
| 204 | 233 | it.live("remove non-existent directory succeeds silently", () => | |
| 205 | 234 | provideTmpdirInstance( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments