From 87192e49c6842e52499dd828a618f4e17678c503 Mon Sep 17 00:00:00 2001 From: Aunali321 Date: Mon, 1 Aug 2022 23:42:38 +0530 Subject: [PATCH] feat: fetching contributors from GIthub API. --- lib/backend/api/github_api.dart | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/backend/api/github_api.dart b/lib/backend/api/github_api.dart index a9174976..5dd8510d 100644 --- a/lib/backend/api/github_api.dart +++ b/lib/backend/api/github_api.dart @@ -16,9 +16,10 @@ class GithubAPI { } Future latestCommitTime(String org, repoName) async { - var latestCommit = + var repo = await github.repositories.getRepository(RepositorySlug(org, repoName)); - var commitTime = latestCommit.pushedAt?.difference( + + var commitTime = repo.pushedAt?.difference( DateTime.now().toLocal(), ); @@ -38,10 +39,21 @@ class GithubAPI { return "$minutes mins"; } } + + Future contributors(String org, repoName) async { + var contributors = + github.repositories.listContributors(RepositorySlug(org, repoName)); + contributors.forEach((contributor) { + print(contributor.login); + print(contributor.avatarUrl); + }); + return contributors; + } } void main(List args) { GithubAPI githubAPI = GithubAPI(); - githubAPI.latestRelease('revanced', 'revanced-patches'); - githubAPI.latestCommitTime("revanced", "revanced-patches"); + // githubAPI.latestRelease('revanced', 'revanced-patches'); + // githubAPI.latestCommitTime("revanced", "revanced-patches"); + // githubAPI.contributors("revanced", "revanced-manager"); }