All repositories are now fetched
parent
d8d7c88496
commit
15e9c60d4c
19
src/index.js
19
src/index.js
|
@ -7,9 +7,14 @@ async function getGithubRepositories(username, token) {
|
|||
const octokit = new Octokit({
|
||||
auth: token || null,
|
||||
});
|
||||
|
||||
const publicRepositoriesWithForks = await octokit.paginate('GET /users/:username/repos', { username: username })
|
||||
.then(repositories => toRepositoryList(repositories));
|
||||
|
||||
return octokit.paginate('GET /search/repositories?q=user:{username}', { username : username })
|
||||
const allRepositoriesWithoutForks = await octokit.paginate('GET /search/repositories?q=user:{username}', { username : username })
|
||||
.then(repositories => toRepositoryList(repositories));
|
||||
|
||||
return filterDuplicates(allRepositoriesWithoutForks.concat(publicRepositoriesWithForks));
|
||||
}
|
||||
|
||||
function toRepositoryList(repositories) {
|
||||
|
@ -18,6 +23,18 @@ function toRepositoryList(repositories) {
|
|||
});
|
||||
}
|
||||
|
||||
function filterDuplicates(array) {
|
||||
var a = array.concat();
|
||||
for(var i=0; i<a.length; ++i) {
|
||||
for(var j=i+1; j<a.length; ++j) {
|
||||
if(a[i].url === a[j].url)
|
||||
a.splice(j--, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
async function getGiteaUser(gitea) {
|
||||
return request.get(gitea.url
|
||||
+ '/api/v1/user')
|
||||
|
|
Loading…
Reference in New Issue