| 674 | } |
| 675 | |
| 676 | func LastCommit(client *Client, repo ghrepo.Interface) (*Commit, error) { |
| 677 | var responseData struct { |
| 678 | Repository struct { |
| 679 | DefaultBranchRef struct { |
| 680 | Target struct { |
| 681 | Commit `graphql:"... on Commit"` |
| 682 | } |
| 683 | } |
| 684 | } `graphql:"repository(owner: $owner, name: $repo)"` |
| 685 | } |
| 686 | variables := map[string]any{ |
| 687 | "owner": githubv4.String(repo.RepoOwner()), "repo": githubv4.String(repo.RepoName()), |
| 688 | } |
| 689 | if err := client.Query(repo.RepoHost(), "LastCommit", &responseData, variables); err != nil { |
| 690 | return nil, err |
| 691 | } |
| 692 | return &responseData.Repository.DefaultBranchRef.Target.Commit, nil |
| 693 | } |
| 694 | |
| 695 | // RepoFindForks finds forks of the repo that are affiliated with the viewer |
| 696 | func RepoFindForks(client *Client, repo ghrepo.Interface, limit int) ([]*Repository, error) { |