-
I have a non-organisational GitHub repo. I have worked out how to get a list of all the repos for the authenticated user as follows:
However, I am struggling to work out how to get a specific named repo using this library. I do not wish to list all the repos and then search through them to find the one I need. I want to be able to directly get the specific named repo. Is there a way of achieving this? Also, is there a way to get the commit details given its commit SHA (again for a non-organisational repo)? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
const { data: repository} = await octokit.rest.repos.get({owner: "octokit", repo: "octokit.js"}) If you want to get the current user's username, you can do const { data: user } = await octokit.rest.users.getAuthenticated()
// user.login
It's the same for user and org repositories const { data: commit } = await octokit.rest.repos.getCommit({ owner: "octokit", repo: "octokit.js", ref: "46b5f2fd41ef6d2ac23653ca302d6ba7e5559c02" }) |
Beta Was this translation helpful? Give feedback.
If you want to get the current user's username, you can do
It's the same for user and org repositories