Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit f2299d9

Browse files
authored
Merge pull request #1869 from atom/aw/null-repository
UserStore handles GitHub remotes that no longer exist
2 parents 94b8d95 + fe93f9b commit f2299d9

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

lib/models/user-store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export default class UserStore {
175175
console.error(`Error fetching mentionable users:\n${response.errors.map(e => e.message).join('\n')}`);
176176
}
177177

178-
if (!response.data) {
178+
if (!response.data || !response.data.repository) {
179179
break;
180180
}
181181

test/models/user-store.test.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('UserStore', function() {
3838
const opts = {
3939
owner: 'me',
4040
name: 'stuff',
41+
repositoryFound: true,
4142
...options,
4243
};
4344

@@ -50,7 +51,7 @@ describe('UserStore', function() {
5051
name: 'GetMentionableUsers',
5152
variables: {owner: opts.owner, name: opts.name, first: 100, after: lastCursor},
5253
}, {
53-
repository: {
54+
repository: !opts.repositoryFound ? null : {
5455
mentionableUsers: {
5556
nodes: page,
5657
pageInfo: {
@@ -173,6 +174,27 @@ describe('UserStore', function() {
173174
]);
174175
});
175176

177+
it('skips GitHub remotes that no longer exist', async function() {
178+
await login.setToken('https://api.github.com', '1234');
179+
180+
const workdirPath = await cloneRepository('multiple-commits');
181+
const repository = await buildRepository(workdirPath);
182+
183+
await repository.setConfig('remote.origin.url', '[email protected]:me/stuff.git');
184+
await repository.setConfig('remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*');
185+
186+
const [{resolve, promise}] = expectPagedRelayQueries({repositoryFound: false}, []);
187+
188+
store = new UserStore({repository, login, config});
189+
await nextUpdatePromise();
190+
191+
resolve();
192+
// nextUpdatePromise will not fire because the update is empty
193+
await promise;
194+
195+
assert.deepEqual(store.getUsers(), []);
196+
});
197+
176198
it('infers no-reply emails for users without a public email address', async function() {
177199
await login.setToken('https://api.github.com', '1234');
178200

@@ -406,8 +428,8 @@ describe('UserStore', function() {
406428
const actualToken = await store.getToken(loginModel, 'https://api.github.com');
407429
assert.strictEqual(expectedToken, actualToken);
408430
});
409-
410431
});
432+
411433
describe('loadMentionableUsers', function() {
412434
it('returns undefined if token is null', async function() {
413435
const workdirPath = await cloneRepository('multiple-commits');

0 commit comments

Comments
 (0)