| 467 | // For "auto", git picks "#" unless a message line already starts with it. |
| 468 | // We always use "#" here (git removes auto in 3.0). |
| 469 | async function getGitCommentString(cwd: string): Promise<string> { |
| 470 | const result = x("git", ["config", "--get-regexp", "^core\\.comment(char|string)$"], { |
| 471 | nodeOptions: { cwd }, |
| 472 | }); |
| 473 | const output = await result; |
| 474 | |
| 475 | if (result.exitCode && result.exitCode > 1) { |
| 476 | console.warn( |
| 477 | "Could not determine core.commentChar/core.commentString git configuration", |
| 478 | output.stderr, |
| 479 | ); |
| 480 | return gitDefaultCommentChar; |
| 481 | } |
| 482 | |
| 483 | const value = output.stdout |
| 484 | .split("\n") |
| 485 | .filter(Boolean) |
| 486 | .pop() |
| 487 | ?.replace(/^\S+ ?/, ""); |
| 488 | return !value || value.toLowerCase() === "auto" ? gitDefaultCommentChar : value; |
| 489 | } |
| 490 | |
| 491 | function getEditValue(flags: CliFlags) { |
| 492 | if (flags.env) { |