All repositories are now fetched

pull/1/head
MasterEvarior 2021-05-02 18:03:16 +02:00
parent d8d7c88496
commit 15e9c60d4c
1 changed files with 18 additions and 1 deletions

View File

@ -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')