Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 12
fix(docker): allow swap and network configuration#308
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
aba08daff1bc75109be65eeb3d2ae5a519aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -35,6 +35,12 @@ const expandHome = (value: string, home: string | null): string => { | ||
| const trimTrailingSlash = (value: string): string => { | ||
| let end = value.length | ||
| while (end > 0) { | ||
| if (end === 1 && value[0] === "/") { | ||
| break | ||
| } | ||
| if (end === 3 && /^[a-z]:[\\/]/iu.test(value.slice(0, end))) { | ||
| break | ||
| } | ||
| const char = value[end - 1] | ||
| if (char !== "/" && char !== "\\") { | ||
| break | ||
| @@ -44,14 +50,23 @@ const trimTrailingSlash = (value: string): string => { | ||
| return value.slice(0, end) | ||
| } | ||
| const homePathSeparator = (home: string): string => home.includes("\\") && !home.includes("/") ? "\\" : "/" | ||
| const joinHomePath = (home: string, child: string): string => { | ||
| const root = trimTrailingSlash(home) | ||
| return root.endsWith("/") || root.endsWith("\\") | ||
| ? `${root}${child}` | ||
| : `${root}${homePathSeparator(root)}${child}` | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| export const defaultProjectsRoot = (cwd: string): string => { | ||
| const home = resolveHomeDir() | ||
| const explicit = process.env["DOCKER_GIT_PROJECTS_ROOT"]?.trim() | ||
| if (explicit && explicit.length > 0) { | ||
| return expandHome(explicit, home) | ||
| } | ||
| if (home !== null) { | ||
| return `${trimTrailingSlash(home)}/.docker-git` | ||
| return joinHomePath(home, ".docker-git") | ||
| } | ||
| return `${cwd}/.docker-git` | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,6 +30,46 @@ const parsePort = (value: string): Either.Either<number, ParseError> => { | ||
| return Either.right(parsed) | ||
| } | ||
| const isAsciiLetterCode = (code: number): boolean => (code >= 65 && code <= 90) || (code >= 97 && code <= 122) | ||
| const isPathSeparator = (value: string | undefined): boolean => value === "/" || value === "\\" | ||
| const rootPathLength = (value: string): number => { | ||
| if (isPathSeparator(value[0])) { | ||
| return 1 | ||
| } | ||
| if ( | ||
| value.length >= 3 && | ||
| isAsciiLetterCode(value.codePointAt(0) ?? 0) && | ||
| value[1] === ":" && | ||
| isPathSeparator(value[2]) | ||
| ) { | ||
| return 3 | ||
| } | ||
| return 0 | ||
| } | ||
| /** | ||
| * Removes redundant trailing path separators while preserving filesystem roots. | ||
| * | ||
| * @param value - Path text decoded from CLI/config input. | ||
| * @returns The input without trailing `/` or `\\` separators unless the input is a root path. | ||
| * @pure true | ||
| * @effect none; CORE helper only scans the provided string. | ||
| * @invariant roots `/`, `\\`, `C:\\`, and `C:/` remain non-empty root paths. | ||
| * @precondition value is a string and may be empty or contain mixed separators. | ||
| * @postcondition non-root results do not end with `/` or `\\`; root results are preserved. | ||
| * @complexity O(n) time / O(1) space where n = |value|. | ||
| */ | ||
| export const trimTrailingPathSeparators = (value: string): string => { | ||
| let end = value.length | ||
| const minEnd = rootPathLength(value) | ||
| while (end > minEnd && isPathSeparator(value[end - 1])) { | ||
| end -= 1 | ||
| } | ||
| return value.slice(0, end) | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| /** | ||
| * Parses a raw SSH port value into the valid Docker host-port range. | ||
| * | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.