From cb3ccbb4f64569117905b4a766367c1bba49aae5 Mon Sep 17 00:00:00 2001 From: Maksim Syomochkin Date: Tue, 7 Dec 2021 15:17:19 +0300 Subject: [PATCH] Add overwrite button --- src/extension.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index d46d62e..4751de0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -42,7 +42,11 @@ export async function activate() { }); if (gitConfig.length === 0) { console.error("Missing user creds in git"); - vscode.window.showErrorMessage("Missing user creds in git"); + const option = await vscode.window.showErrorMessage("Missing user creds in git", "Overwrite"); + if (option && option === "Overwrite") { + await repository.setConfig("user.name", name); + await repository.setConfig("user.email", email); + } return; } gitConfig.forEach(c => { @@ -61,7 +65,11 @@ export async function activate() { }); if (gitName !== name || gitEmail !== email) { console.error("Wrong user settings in git"); - vscode.window.showErrorMessage("Wrong user settings in git"); + const option = await vscode.window.showErrorMessage("Wrong user settings in git", "Overwrite"); + if (option && option === "Overwrite") { + await repository.setConfig("user.name", name); + await repository.setConfig("user.email", email); + } } } });