@@ -3,6 +3,7 @@ import { type Extension, extensions, window } from "vscode";
33import type { API as GitApi , GitExtension , Repository } from "../@types/git" ;
44import { CONSTANTS } from "../Constants" ;
55import WorkspaceService from "./WorkspaceService" ;
6+ import { logger } from "../utils/log" ;
67
78class GitService {
89 static _instance : GitService ;
@@ -96,23 +97,27 @@ class GitService {
9697 window . showInformationMessage ( `${ CONSTANTS . extensionShortName } : ${ msg } ` ) ;
9798 }
9899
99- async getDiffAndWarnUser ( repo : Repository , cached = true , nameOnly ?: boolean ) {
100+ async getDiff ( repo : Repository , cached = true , nameOnly ?: boolean ) : Promise < string > {
100101 const diff = await this . getGitDiff ( repo , cached , nameOnly ) ;
101102 if ( ! diff ) {
102103 if ( cached ) {
103104 const diffUncached = await repo . diff ( false ) ;
104105 if ( diffUncached ) {
105- this . showInformationMessage ( "warning : please stage your git changes") ;
106+ throw new Error ( "Warning : please stage your git changes") ;
106107 } else {
107- this . showInformationMessage ( "No Changes" ) ;
108+ throw new Error ( "No Changes" ) ;
108109 }
109- return null ;
110110 }
111- this . showInformationMessage ( "No changes" ) ;
111+ throw new Error ( "No changes" ) ;
112112 }
113113 return diff ;
114114 }
115-
115+ async getDiffAndWarnUser ( repo : Repository , cached = true , nameOnly ?: boolean ) {
116+ return this . getDiff ( repo , cached , nameOnly ) . catch ( ( error ) => {
117+ this . showInformationMessage ( error . message ) ;
118+ return null ;
119+ } ) ;
120+ }
116121 /**
117122 * Check if a file path matches any of the exclusion patterns
118123 * @param filePath - The file path to check
@@ -252,7 +257,7 @@ class GitService {
252257
253258 return gitExtension . getAPI ( 1 ) ;
254259 }
255- } catch { }
260+ } catch { }
256261
257262 return undefined ;
258263 }
0 commit comments