| 140 | } |
| 141 | |
| 142 | async function readConfigString( |
| 143 | opts: CommitWithDeps, |
| 144 | dir: string, |
| 145 | path: string, |
| 146 | ): Promise<string | undefined> { |
| 147 | try { |
| 148 | const value = await opts.git.getConfig({ fs: opts.fs, dir, path }); |
| 149 | return typeof value === "string" && value.length > 0 ? value : undefined; |
| 150 | } catch { |
| 151 | // A missing config file or unreadable key is not an error |
| 152 | // here; identity resolution just falls through to the next |
| 153 | // source. |
| 154 | return undefined; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | function errorMessage(cause: unknown): string { |
| 159 | if (cause instanceof Error) return cause.message; |