Skip to content

Commit 036a2e6

Browse files
authored
Chat participant wrongly claims there are not GitHub remotes, when not logged in (#6505)
Fixes #6502
1 parent c0480ac commit 036a2e6

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/common/authentication.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import * as vscode from 'vscode';
7+
68
export enum GitHubServerType {
79
None,
810
GitHubDotCom,
@@ -15,8 +17,8 @@ export enum AuthProvider {
1517
}
1618

1719
export class AuthenticationError extends Error {
18-
constructor(message: string) {
19-
super(message);
20+
constructor() {
21+
super(vscode.l10n.t('Not authenticated'));
2022
}
2123
}
2224

src/github/githubRepository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class GitHubRepository extends Disposable {
157157
if (!this._initialized) {
158158
throw new Error('Call ensure() before accessing this property.');
159159
} else {
160-
throw new AuthenticationError('Not authenticated.');
160+
throw new AuthenticationError();
161161
}
162162
}
163163
return this._hub;

src/lm/tools/toolsUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import { AuthProvider } from '../../common/authentication';
7+
import { AuthenticationError, AuthProvider } from '../../common/authentication';
88
import { CredentialStore, GitHub } from '../../github/credentials';
99
import { FolderRepositoryManager } from '../../github/folderRepositoryManager';
1010
import { RepositoriesManager } from '../../github/repositoriesManager';
@@ -55,6 +55,10 @@ export abstract class RepoToolBase<T> extends ToolBase<T> {
5555
}
5656

5757
protected async getRepoInfo(options: { owner?: string, name?: string }): Promise<{ owner: string; name: string; folderManager: FolderRepositoryManager }> {
58+
if (!this.credentialStore.isAnyAuthenticated()) {
59+
throw new AuthenticationError();
60+
}
61+
5862
let owner: string | undefined;
5963
let name: string | undefined;
6064
let folderManager: FolderRepositoryManager | undefined;

0 commit comments

Comments
 (0)