Skip to content

Commit

Permalink
Chat participant wrongly claims there are not GitHub remotes, when no…
Browse files Browse the repository at this point in the history
…t logged in

Fixes #6502
  • Loading branch information
alexr00 committed Dec 3, 2024
1 parent 268854f commit e1504e8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/common/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';

export enum GitHubServerType {
None,
GitHubDotCom,
Expand All @@ -15,8 +17,8 @@ export enum AuthProvider {
}

export class AuthenticationError extends Error {
constructor(message: string) {
super(message);
constructor() {
super(vscode.l10n.t('Not authenticated'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/github/githubRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class GitHubRepository extends Disposable {
if (!this._initialized) {
throw new Error('Call ensure() before accessing this property.');
} else {
throw new AuthenticationError('Not authenticated.');
throw new AuthenticationError();
}
}
return this._hub;
Expand Down
6 changes: 5 additions & 1 deletion src/lm/tools/toolsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { AuthProvider } from '../../common/authentication';
import { AuthenticationError, AuthProvider } from '../../common/authentication';
import { CredentialStore, GitHub } from '../../github/credentials';
import { FolderRepositoryManager } from '../../github/folderRepositoryManager';
import { RepositoriesManager } from '../../github/repositoriesManager';
Expand Down Expand Up @@ -55,6 +55,10 @@ export abstract class RepoToolBase<T> extends ToolBase<T> {
}

protected async getRepoInfo(options: { owner?: string, name?: string }): Promise<{ owner: string; name: string; folderManager: FolderRepositoryManager }> {
if (!this.credentialStore.isAnyAuthenticated()) {
throw new AuthenticationError();
}

let owner: string | undefined;
let name: string | undefined;
let folderManager: FolderRepositoryManager | undefined;
Expand Down

0 comments on commit e1504e8

Please sign in to comment.