MCPcopy Create free account
hub / github.com/cli/cli / LastCommit

Function LastCommit

api/queries_repo.go:676–693  ·  view source on GitHub ↗
(client *Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

674}
675
676func 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
696func RepoFindForks(client *Client, repo ghrepo.Interface, limit int) ([]*Repository, error) {

Callers 1

LastCommitMethod · 0.92

Calls 5

StringMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
QueryMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected