@@ -71,14 +71,15 @@ const registerGitProvider = async (context: vscode.ExtensionContext, repositoryM
7171
7272 git . onDidCloseRepository ( ( repo : GitRepository ) => {
7373 repositoryManager . close ( repo )
74- // If there are no more repositories, set context to false
74+ // Only set context to false if there are truly no repositories left
7575 if ( git . repositories . length === 0 ) {
7676 vscode . commands . executeCommand ( 'setContext' , 'codacy:isGitRepository' , false )
7777 }
7878 } )
7979
8080 git . onDidChangeState ( async ( state : APIState ) => {
8181 if ( state === 'initialized' ) {
82+ // Only set the context after we know the final state
8283 if ( git . repositories . length > 0 ) {
8384 await vscode . commands . executeCommand ( 'setContext' , 'codacy:isGitRepository' , true )
8485 repositoryManager . open ( git . repositories [ 0 ] )
@@ -94,7 +95,8 @@ const registerGitProvider = async (context: vscode.ExtensionContext, repositoryM
9495
9596 return git
9697 } else {
97- // If git provider is not found, set context to false
98+ // Only set context to false if Git is truly not available
99+ Logger . error ( 'Native Git VSCode extension not found' )
98100 await vscode . commands . executeCommand ( 'setContext' , 'codacy:isGitRepository' , false )
99101 }
100102}
@@ -135,8 +137,10 @@ export async function activate(context: vscode.ExtensionContext) {
135137
136138 await vscode . commands . executeCommand ( 'setContext' , 'codacy:windowsDetected' , os . platform ( ) === 'win32' )
137139
138- // Set isGitRepository to false by default, will be updated by git provider logic
139- await vscode . commands . executeCommand ( 'setContext' , 'codacy:isGitRepository' , false )
140+ // Set isGitRepository to null by default, will be properly set by git provider logic
141+ // Using null instead of false prevents overriding the context when it shouldn't
142+ // This will ensure we don't set it to false when a repository is actually available
143+ await vscode . commands . executeCommand ( 'setContext' , 'codacy:isGitRepository' , null )
140144
141145 if ( hasWorkspaceFolder ) {
142146 Logger . appendLine ( 'Codacy extension activated with workspace folder' )
0 commit comments