Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat participant wrongly claims there are not GitHub remotes, when not logged in #6505

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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