File tree Expand file tree Collapse file tree
extensions/ql-vscode/src/databases Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,9 +39,24 @@ async function findRepositoryForWorkspaceFolder(
3939 ) ;
4040}
4141
42+ /**
43+ * Finds the primary remote fetch URL for a repository.
44+ *
45+ * The priority is:
46+ * 1. The remote associated with the current branch
47+ * 2. The remote named "origin"
48+ * 3. The first remote
49+ *
50+ * If none of these are found, undefined is returned.
51+ *
52+ * @param repository The repository to find the remote for.
53+ */
4254async function findRemote ( repository : Repository ) : Promise < string | undefined > {
4355 // Try to retrieve the remote 5 times with a 5 second delay between each attempt.
44- // This is to account for the case where the Git extension is still initializing.
56+ // This is to account for the case where the Git extension has not yet retrieved
57+ // the state for all Git repositories.
58+ // This can happen on Codespaces where the Git extension is initialized before the
59+ // filesystem is ready.
4560 for ( let count = 0 ; count < 5 ; count ++ ) {
4661 const remoteName = repository . state . HEAD ?. upstream ?. remote ?? "origin" ;
4762 const originRemoteUrl = repository . state . remotes . find (
@@ -56,7 +71,7 @@ async function findRemote(repository: Repository): Promise<string | undefined> {
5671 return firstRemoteUrl ;
5772 }
5873
59- // Wait for Git to initialize .
74+ // Wait for 5 seconds before trying again .
6075 await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) ) ;
6176 }
6277
You can’t perform that action at this time.
0 commit comments