/** * Parsed representation of a git URL accepted by `vat audit`. * * - `cloneUrl` is the URL passed to `git clone` (after stripping ref/subpath * fragments and after expanding GitHub shorthand to a full HTTPS URL). * - `ref` is an optional branch or tag name (deep commit SHAs are not * guaranteed to work with shallow clone — see design spec for details). * - `subpath` is an optional subdirectory within the cloned repo to audit. * - `inferredFromShorthand` records whether `cloneUrl` was *inferred* from bare * `owner/repo` shorthand rather than supplied verbatim by the user. */ export interface ParsedGitUrl { cloneUrl: string; ref?: string; subpath?: string; /** * True when `cloneUrl` was synthesized from bare GitHub shorthand * (`owner/repo`), false when the user typed a URL we pass through. * * This has to travel with the value: an expanded shorthand URL is * byte-identical to a hand-typed one, so a consumer cannot recover the * distinction by inspecting `cloneUrl`. Consumers need it because the two * cases warrant opposite credential policies — see * {@link nonInteractiveGitOverrides}. */ inferredFromShorthand: boolean; } /** * Environment and `git -c` overrides that make a clone non-interactive. * Both collections are empty when no override is warranted. */ export interface NonInteractiveGitOverrides { /** Overlay to merge over `process.env` when spawning git. */ env: Record; /** `git -c =` arguments to place *before* the subcommand. */ configArgs: string[]; } /** * Parse a string into a {@link ParsedGitUrl}. * * Accepted forms: * - `https://host/owner/repo.git` * - `https://host/owner/repo.git#ref` * - `https://host/owner/repo.git#ref:subpath` * - `https://github.com/owner/repo/tree//` (GitHub web URL) * - `owner/repo` (GitHub shorthand → expanded to HTTPS) * - `git@host:owner/repo.git` * - `ssh://git@host/owner/repo.git` * * Throws on malformed input. */ export declare function parseGitUrl(input: string): ParsedGitUrl; /** * Credential-prompt overrides for cloning `parsed`. * * **Only inferred shorthand gets them.** A user who typed a full * `https://…` URL for a private repo may legitimately intend to authenticate * interactively, and silently disabling that would break a real workflow. A * user who typed `owner/repo` and got it wrong should fail in milliseconds * instead of sitting on a credential prompt for a minute. * * Why this exact set (verified against git 2.50.1 with `git credential fill`): * * - `GIT_TERMINAL_PROMPT=0` — suppresses git's own TTY prompt. On its own it is * **not** sufficient: `gitcredentials(7)` consults `GIT_ASKPASS`, then * `core.askPass`, then `SSH_ASKPASS`, and only prompts on the terminal if all * three are unset. Each askpass hook therefore bypasses this flag entirely — * which is exactly the case inside VS Code's integrated terminal, where * `GIT_ASKPASS` points at a GUI prompt. * - `GIT_ASKPASS=''` — `getenv()` returns a non-NULL empty string, so git stops * walking the askpass chain *and* runs nothing, masking `core.askPass` and * `SSH_ASKPASS` in one move. * - `SSH_ASKPASS=''` and `-c core.askPass=` — belt and braces for the same * chain, because an empty-valued environment variable is not reliably * distinguishable from an unset one on Windows. `-c` is used rather than * `GIT_CONFIG_*` precisely because `-c` is additive: writing * `GIT_CONFIG_COUNT` would silently clobber an overlay the caller supplied * (VAT's own tests use `GIT_CONFIG_*` to rewrite remotes via `insteadOf`). * - `GCM_INTERACTIVE=never` — git's flags cannot reach a credential *helper* * that opens its own UI. Git Credential Manager (the default on Git for * Windows) is the common one; `never` still lets it serve a cached * credential, it only forbids escalating to a prompt. * * What is deliberately **not** here: nothing resets `credential.helper` and * nothing sets `GIT_CONFIG_NOSYSTEM`. A helper holding a valid token is how a * private repo typed as shorthand still clones successfully; the goal is to * forbid *interaction*, not authentication. */ export declare function nonInteractiveGitOverrides(parsed: ParsedGitUrl): NonInteractiveGitOverrides; /** * Detect whether a string should be treated as a git URL (for the polymorphic * `[git-url-or-path]` audit argument). True for: * - http(s):// URLs * - ssh:// URLs * - file:// URLs (used by integration tests against local bare repos) * - git@host:path scp-style URLs * - GitHub shorthand `owner/repo` (strict — no extensions, no extra slashes) * * Everything else (including relative paths like `./foo/bar`, absolute paths, * and multi-segment paths like `foo/bar/baz`) is treated as a filesystem path. */ export declare function isGitUrl(input: string): boolean; //# sourceMappingURL=git-url.d.ts.map