Skip to content

Commit f67744e

Browse files
committed
Fix for incorrect GitHub error when working in non-GitHub repos
1 parent b623952 commit f67744e

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

app/src/lib/github/service.test.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@ import { BehaviorSubject } from 'rxjs';
33
import { expect, test, describe } from 'vitest';
44

55
const exampleRemoteUrls = [
6-
'ssh://user@host.xz:123/org/repo.git/',
7-
'ssh://user@host.xz/org/repo.git/',
8-
'ssh://host.xz:123/org/repo.git/',
9-
'ssh://host.xz:123/org/repo',
10-
'ssh://host.xz/org/repo.git/',
11-
'ssh://host.xz/org/repo.git',
12-
'ssh://host.xz/org/repo',
13-
'ssh://user@host.xz/org/repo.git/',
14-
'ssh://user@host.xz/org/repo.git',
15-
'ssh://user@host.xz/org/repo',
16-
'host.xz:org/repo.git/',
17-
'host.xz:org/repo.git',
18-
'host.xz:org/repo',
19-
'user@host.xz:org/repo.git/',
20-
'user@host.xz:org/repo.git',
21-
'user@host.xz:org/repo',
226
'git@github.com:org/repo.git/',
237
'git@github.com:org/repo.git',
248
'git@github.com:org/repo',

app/src/lib/github/service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ export class GitHubService {
7070
combineLatest([accessToken$, remoteUrl$])
7171
.pipe(
7272
tap(([accessToken, remoteUrl]) => {
73-
if (!accessToken) {
73+
// We check the remote url since GitHub is currently enabled at the account
74+
// level rather than project level.
75+
if (!accessToken || !remoteUrl?.includes('github.com')) {
7476
return of();
7577
}
7678
this._octokit = new Octokit({
@@ -91,8 +93,8 @@ export class GitHubService {
9193
combineLatest([this.reload$, accessToken$, remoteUrl$])
9294
.pipe(
9395
tap(() => this.error$.next(undefined)),
94-
switchMap(([reload, _token, remoteUrl]) => {
95-
if (!this.isEnabled || !remoteUrl) return EMPTY;
96+
switchMap(([reload, _token, _remoteUrl]) => {
97+
if (!this._octokit || !this._owner) return EMPTY;
9698
const prs = this.fetchPrs(!!reload?.skipCache);
9799
this.fresh$.next();
98100
return prs;

0 commit comments

Comments
 (0)