Git - 💄 better error handling and clean-up logging (#219975)

This commit is contained in:
Ladislau Szomoru
2024-07-04 17:12:06 +02:00
committed by GitHub
parent e852c335aa
commit 83c722d9a1
3 changed files with 129 additions and 109 deletions

View File

@@ -22,7 +22,7 @@ export class GitProtocolHandler implements UriHandler {
}
handleUri(uri: Uri): void {
this.logger.info(`GitProtocolHandler.handleUri(${uri.toString()})`);
this.logger.info(`[GitProtocolHandler] handleUri(${uri.toString()})`);
switch (uri.path) {
case '/clone': this.clone(uri);
@@ -34,17 +34,17 @@ export class GitProtocolHandler implements UriHandler {
const ref = data.ref;
if (!data.url) {
this.logger.warn('Failed to open URI:' + uri.toString());
this.logger.warn('[GitProtocolHandler] Failed to open URI:' + uri.toString());
return;
}
if (Array.isArray(data.url) && data.url.length === 0) {
this.logger.warn('Failed to open URI:' + uri.toString());
this.logger.warn('[GitProtocolHandler] Failed to open URI:' + uri.toString());
return;
}
if (ref !== undefined && typeof ref !== 'string') {
this.logger.warn('Failed to open URI due to multiple references:' + uri.toString());
this.logger.warn('[GitProtocolHandler] Failed to open URI due to multiple references:' + uri.toString());
return;
}
@@ -69,12 +69,12 @@ export class GitProtocolHandler implements UriHandler {
}
}
catch (ex) {
this.logger.warn('Invalid URI:' + uri.toString());
this.logger.warn('[GitProtocolHandler] Invalid URI:' + uri.toString());
return;
}
if (!(await commands.getCommands(true)).includes('git.clone')) {
this.logger.error('Could not complete git clone operation as git installation was not found.');
this.logger.error('[GitProtocolHandler] Could not complete git clone operation as git installation was not found.');
const errorMessage = l10n.t('Could not clone your repository as Git is not installed.');
const downloadGit = l10n.t('Download Git');
@@ -86,7 +86,7 @@ export class GitProtocolHandler implements UriHandler {
return;
} else {
const cloneTarget = cloneUri.toString(true);
this.logger.info(`Executing git.clone for ${cloneTarget}`);
this.logger.info(`[GitProtocolHandler] Executing git.clone for ${cloneTarget}`);
commands.executeCommand('git.clone', cloneTarget, undefined, { ref: ref });
}
}