Repository navigation
feat(server,web): choose where new worktrees are created #16231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
bc540a1
feat(server,web): choose where new worktrees are created
juliusmarminge a1884a2
fix(server,web): keep old worktree locations managed and reject drive…
juliusmarminge 677a70c
fix(server): skip unresolvable or symlinked-root worktree locations
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type * as Path from "effect/Path"; | ||
|
|
||
| import { expandHomePathWith } from "./pathExpansion.ts"; | ||
|
|
||
| /** | ||
| * Directory new worktrees are created under: the `worktreesDirectory` | ||
| * setting, or `defaultDir` (`<T3 home>/worktrees`) when it is empty. Null when | ||
| * the setting is not an absolute path on this machine, such as `D:\worktrees` | ||
| * configured for a Windows server and synced to a Linux one, or when it is a | ||
| * filesystem root, which would make every path on that drive look managed. | ||
| */ | ||
| export function resolveWorktreesDirectory( | ||
| setting: string, | ||
| defaultDir: string, | ||
| path: Path.Path, | ||
| ): string | null { | ||
| if (setting === "") return defaultDir; | ||
| const expanded = expandHomePathWith(setting, path); | ||
| if (!path.isAbsolute(expanded)) return null; | ||
| const resolved = path.resolve(expanded); | ||
| return isFilesystemRoot(resolved, path) ? null : resolved; | ||
| } | ||
|
|
||
| /** Callers re-check after resolving symlinks: a link can point at a root. */ | ||
| export function isFilesystemRoot(directory: string, path: Path.Path): boolean { | ||
| return path.dirname(directory) === directory; | ||
| } | ||
|
|
||
| /** Every directory that holds T3-managed worktrees on this machine. */ | ||
| export function managedWorktreesDirectories( | ||
| settings: { | ||
| readonly worktreesDirectory: string; | ||
| readonly previousWorktreesDirectories: ReadonlyArray<string>; | ||
| }, | ||
| defaultDir: string, | ||
| path: Path.Path, | ||
| ): ReadonlyArray<string> { | ||
| const directories = new Set([defaultDir]); | ||
|
macroscopeapp[bot] marked this conversation as resolved.
|
||
| for (const setting of [settings.worktreesDirectory, ...settings.previousWorktreesDirectories]) { | ||
| const directory = resolveWorktreesDirectory(setting, defaultDir, path); | ||
| if (directory !== null) directories.add(directory); | ||
| } | ||
| return [...directories]; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.