-
Notifications
You must be signed in to change notification settings - Fork 125
backend: add ListPullRequestsWithCommit into Github APIs #1899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
4bd6521
a88cb3d
f25662f
7b62df1
058fb3a
970b48e
1f45288
86e1fde
00e9a3c
b4651bc
d36be40
8a25fd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,7 @@ type Client interface { | |
| GetRepository(ctx context.Context, ref *RemoteRef) (*Repository, error) | ||
| GetOrganization(ctx context.Context, organization string) (*githubv3.Organization, error) | ||
| ListOrganizations(ctx context.Context, user string) ([]*githubv3.Organization, error) | ||
| ListPullRequestsWithCommit(ctx context.Context, ref *RemoteRef, sha string) ([]*PullRequestInfo, error) | ||
| GetOrgMembership(ctx context.Context, user, org string) (*githubv3.Membership, error) | ||
| GetUser(ctx context.Context, username string) (*githubv3.User, error) | ||
| } | ||
|
|
@@ -117,8 +118,9 @@ func (s *svc) CreateIssueComment(ctx context.Context, ref *RemoteRef, number int | |
| } | ||
|
|
||
| type PullRequestInfo struct { | ||
| Number int | ||
| HTMLURL string | ||
| Number int | ||
| HTMLURL string | ||
| BranchName string | ||
| } | ||
|
|
||
| type svc struct { | ||
|
|
@@ -216,6 +218,10 @@ func boolPtr(b bool) *bool { | |
| return &b | ||
| } | ||
|
|
||
| func intPtr(i int) *int { | ||
| return &i | ||
| } | ||
mengmichael1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| func (s *svc) CreatePullRequest(ctx context.Context, ref *RemoteRef, base, title, body string) (*PullRequestInfo, error) { | ||
| req := &githubv3.NewPullRequest{ | ||
| Title: strPtr(title), | ||
|
|
@@ -236,6 +242,25 @@ func (s *svc) CreatePullRequest(ctx context.Context, ref *RemoteRef, base, title | |
| }, nil | ||
| } | ||
|
|
||
| func (s *svc) ListPullRequestsWithCommit(ctx context.Context, ref *RemoteRef, sha string) ([]*PullRequestInfo, error) { | ||
|
||
| // PullRequestListOptions left as nil since default opts are sufficient (State: "open", Sort: "created") | ||
| respPRs, _, err := s.rest.PullRequests.ListPullRequestsWithCommit(ctx, ref.RepoOwner, ref.RepoName, sha, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| prInfos := make([]*PullRequestInfo, len(respPRs)) | ||
| for i, pr := range respPRs { | ||
| prInfos[i] = &PullRequestInfo{ | ||
| Number: pr.GetNumber(), | ||
| HTMLURL: pr.GetHTMLURL(), | ||
| BranchName: pr.GetHead().GetRef(), | ||
| } | ||
| } | ||
|
|
||
| return prInfos, nil | ||
| } | ||
|
|
||
| type CreateBranchRequest struct { | ||
| // The base for the new branch. | ||
| Ref *RemoteRef | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.