From 6081edff8ab3eb0874f2f667cb9f26a346bbde28 Mon Sep 17 00:00:00 2001 From: Sergio Padrino Date: Wed, 13 Mar 2024 13:52:23 +0100 Subject: [PATCH] Add parseBadConfigValueErrorInfo function --- lib/git-process.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/git-process.ts b/lib/git-process.ts index def68479..8789fe50 100644 --- a/lib/git-process.ts +++ b/lib/git-process.ts @@ -291,6 +291,30 @@ export class GitProcess { return null } + + public static parseBadConfigValueErrorInfo( + stderr: string + ): { key: string; value: string } | null { + const errorEntry = Object.entries(GitErrorRegexes).find( + ([_, v]) => v === GitError.BadConfigValue + ) + + if (errorEntry === undefined) { + return null + } + + const m = stderr.match(errorEntry[0]) + + if (m === null) { + return null + } + + if (!m[1] || !m[2]) { + return null + } + + return { key: m[2], value: m[1] } + } } /**