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

Function ComparePullRequestBaseBranchWith

api/queries_pr.go:886–919  ·  view source on GitHub ↗
(client *Client, repo ghrepo.Interface, prNumber int, headRef string)

Source from the content-addressed store, hash-verified

884}
885
886func ComparePullRequestBaseBranchWith(client *Client, repo ghrepo.Interface, prNumber int, headRef string) (*RefComparison, error) {
887 query := `query ComparePullRequestBaseBranchWith($owner: String!, $repo: String!, $pullRequestNumber: Int!, $headRef: String!) {
888 repository(owner: $owner, name: $repo) {
889 pullRequest(number: $pullRequestNumber) {
890 baseRef {
891 compare (headRef: $headRef) {
892 aheadBy, behindBy, status
893 }
894 }
895 }
896 }
897 }`
898
899 var result struct {
900 Repository struct {
901 PullRequest struct {
902 BaseRef struct {
903 Compare RefComparison
904 }
905 }
906 }
907 }
908 variables := map[string]any{
909 "owner": repo.RepoOwner(),
910 "repo": repo.RepoName(),
911 "pullRequestNumber": prNumber,
912 "headRef": headRef,
913 }
914
915 if err := client.GraphQL(repo.RepoHost(), query, variables, &result); err != nil {
916 return nil, err
917 }
918 return &result.Repository.PullRequest.BaseRef.Compare, nil
919}

Callers 1

updateBranchRunFunction · 0.92

Calls 4

GraphQLMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected