( client: GitClient, args: string[], input: GitCliInput, )
| 946 | // --------------------------------------------------------------- |
| 947 | |
| 948 | async function runSymbolicRef( |
| 949 | client: GitClient, |
| 950 | args: string[], |
| 951 | input: GitCliInput, |
| 952 | ): Promise<GitCliResult> { |
| 953 | // Limited surface: only `git symbolic-ref HEAD` and the bare |
| 954 | // `git symbolic-ref` (which behaves like the previous form). |
| 955 | const parsed = parseFlags(args, { |
| 956 | short: { kind: "bool" }, |
| 957 | quiet: { kind: "bool", alias: ["q"] }, |
| 958 | }); |
| 959 | if ("error" in parsed) { |
| 960 | return { stdout: "", stderr: `git symbolic-ref: ${parsed.error}\n`, exitCode: 129 }; |
| 961 | } |
| 962 | const ref = parsed.positional[0] ?? "HEAD"; |
| 963 | if (ref !== "HEAD") { |
| 964 | return { |
| 965 | stdout: "", |
| 966 | stderr: `git symbolic-ref: only HEAD is supported (got ${JSON.stringify(ref)})\n`, |
| 967 | exitCode: 129, |
| 968 | }; |
| 969 | } |
| 970 | const dir = resolveDir(undefined, input.cwd); |
| 971 | try { |
| 972 | const name = await client.currentBranch({ |
| 973 | dir, |
| 974 | fullname: parsed.flags.short !== true, |
| 975 | }); |
| 976 | if (name === undefined) { |
| 977 | // Detached HEAD: real git exits 1 with empty stdout when |
| 978 | // --quiet, otherwise an error message. |
| 979 | if (parsed.flags.quiet) return { stdout: "", stderr: "", exitCode: 1 }; |
| 980 | return { |
| 981 | stdout: "", |
| 982 | stderr: "git symbolic-ref: ref HEAD is not a symbolic ref\n", |
| 983 | exitCode: 1, |
| 984 | }; |
| 985 | } |
| 986 | return { stdout: `${name}\n`, stderr: "", exitCode: 0 }; |
| 987 | } catch (cause) { |
| 988 | return mapGitError("symbolic-ref", cause); |
| 989 | } |
| 990 | } |
| 991 | |
| 992 | // --------------------------------------------------------------- |
| 993 | // ls-files |
no test coverage detected