Fix for incorrect GitHub error when working in non-GitHub repos

This commit is contained in:
Mattias Granlund 2024-06-28 10:57:19 +02:00
parent b623952fdd
commit f67744eea1
2 changed files with 5 additions and 19 deletions

View File

@ -3,22 +3,6 @@ import { BehaviorSubject } from 'rxjs';
import { expect, test, describe } from 'vitest';
const exampleRemoteUrls = [
'ssh://user@host.xz:123/org/repo.git/',
'ssh://user@host.xz/org/repo.git/',
'ssh://host.xz:123/org/repo.git/',
'ssh://host.xz:123/org/repo',
'ssh://host.xz/org/repo.git/',
'ssh://host.xz/org/repo.git',
'ssh://host.xz/org/repo',
'ssh://user@host.xz/org/repo.git/',
'ssh://user@host.xz/org/repo.git',
'ssh://user@host.xz/org/repo',
'host.xz:org/repo.git/',
'host.xz:org/repo.git',
'host.xz:org/repo',
'user@host.xz:org/repo.git/',
'user@host.xz:org/repo.git',
'user@host.xz:org/repo',
'git@github.com:org/repo.git/',
'git@github.com:org/repo.git',
'git@github.com:org/repo',

View File

@ -70,7 +70,9 @@ export class GitHubService {
combineLatest([accessToken$, remoteUrl$])
.pipe(
tap(([accessToken, remoteUrl]) => {
if (!accessToken) {
// We check the remote url since GitHub is currently enabled at the account
// level rather than project level.
if (!accessToken || !remoteUrl?.includes('github.com')) {
return of();
}
this._octokit = new Octokit({
@ -91,8 +93,8 @@ export class GitHubService {
combineLatest([this.reload$, accessToken$, remoteUrl$])
.pipe(
tap(() => this.error$.next(undefined)),
switchMap(([reload, _token, remoteUrl]) => {
if (!this.isEnabled || !remoteUrl) return EMPTY;
switchMap(([reload, _token, _remoteUrl]) => {
if (!this._octokit || !this._owner) return EMPTY;
const prs = this.fetchPrs(!!reload?.skipCache);
this.fresh$.next();
return prs;