Github API: How to get user commits from specific repository? #34881
-
|
How to get user commits or pull requests from the specific repository? I can only see getting recent commits from the repository. I only want to get a specific user's commit. Thanks in advance 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
To see commits from specific user to a given repo: b)
|
Beta Was this translation helpful? Give feedback.
-
CommitsAlternative way to get commits with GraphQL API # get the user ID
{
user(login: "hyochan") {
id
}
}
# result
{
"data": {
"user": {
"id": "MDQ6VXNlcjI3NDYxNDYw"
}
}
}
# get the commits from a given repo for the user ID
{
repository(owner: "hyochan", name: "react-native-masonry-list") {
defaultBranchRef {
name
target {
... on Commit {
history(first: 10, author: {id: "MDQ6VXNlcjI3NDYxNDYw"}) {
nodes {
author {
user {
login
}
}
committedDate
abbreviatedOid
message
}
}
}
}
}
}
}
# result
{
"data": {
"repository": {
"defaultBranchRef": {
"name": "main",
"target": {
"history": {
"nodes": [
{
"author": {
"user": {
"login": "hyochan"
}
},
"committedDate": "2022-09-29T05:53:27Z",
"abbreviatedOid": "f899dc5",
"message": "1.4.0"
},
{
"author": {
"user": {
"login": "hyochan"
}
},
"committedDate": "2022-09-29T05:53:09Z",
"abbreviatedOid": "f56db50",
"message": "fix: resolve #47 (#49)\n\n* feat: add `refreshControlProps`\r\n\r\n* build: update packages\r\n\r\n* test: update snapshots"
},
{
"author": {
"user": {
"login": "hyochan"
}
},
"committedDate": "2022-09-05T08:11:31Z",
"abbreviatedOid": "e41449c",
"message": "1.3.3"
},
{
"author": {
"user": {
"login": "hyochan"
}
},
"committedDate": "2022-08-19T05:10:29Z",
"abbreviatedOid": "dfc4fe3",
"message": "fix: set default `onEndReachThreshold` to 0 (#43)\n\n* fix: set default `onEndReachThreshold` to 0\r\n\r\n* fix: linting\r\n\r\n* fix: udpate to new linting rules"
},
{
"author": {
"user": {
"login": "hyochan"
...Pull Requests# list PR's from a given author in a given repo
# see the link below to fine tune the "query"
# https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests
{
search(query: "author:hyochan repo:hyochan/react-native-masonry-list type:pr", type: ISSUE, first: 35) {
issueCount
nodes {
... on PullRequest {
author {
login
}
number
title
state
}
}
}
}
# result
{
"data": {
"search": {
"issueCount": 11,
"nodes": [
{
"author": {
"login": "hyochan"
},
"number": 49,
"title": "fix: resolve #47",
"state": "MERGED"
},
{
"author": {
"login": "hyochan"
},
"number": 43,
"title": "fix: set default `onEndReachThreshold` to 0",
"state": "MERGED"
},
{
"author": {
"login": "hyochan"
},
"number": 34,
"title": "Update example project to RN@0.68",
... |
Beta Was this translation helpful? Give feedback.
-
|
Thank you so much this is so helpful 🙏 |
Beta Was this translation helpful? Give feedback.
Commits
Alternative way to get commits with GraphQL API