Skip to content

Commit

Permalink
Add TransferIssue request
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>
  • Loading branch information
eddiezane committed Aug 6, 2021
1 parent 8f1e5c9 commit 243b7ab
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions prow/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ type IssueClient interface {
ListOpenIssues(org, repo string) ([]Issue, error)
GetIssue(org, repo string, number int) (*Issue, error)
EditIssue(org, repo string, number int, issue *Issue) (*Issue, error)
TransferIssue(org, dstRepo string, number int) (*TransferIssueMutation, error)
}

// PullRequestClient interface for pull request related API actions
Expand Down Expand Up @@ -2112,6 +2113,31 @@ func (c *client) EditIssue(org, repo string, number int, issue *Issue) (*Issue,
return &ret, nil
}

// TransferIssueMutation is a GraphQL mutation struct compatible with shurcooL/githubql's client
type TransferIssueMutation struct {
TransferIssue struct {
Issue struct {
ResourcePath githubql.URI
}
} `graphql:"transferIssue(input: $input)"`
}

//// TransferIssue will move an issue from one repo to another in the same org.
////
//// See https://docs.github.com/en/graphql/reference/mutations#transferissue
func (c *client) TransferIssue(org, dstRepo string, number int) (*TransferIssueMutation, error) {
durationLogger := c.log("TransferIssue", org, dstRepo, number)
defer durationLogger()

m := &TransferIssueMutation{}
input := githubql.TransferIssueInput{
IssueID: githubql.ID(number),
RepositoryID: githubql.ID(dstRepo),
}
err := c.gqlc.MutateWithGitHubAppsSupport(context.Background(), m, input, nil, org)
return m, err
}

// GetPullRequestPatch gets the patch version of a pull request.
//
// See https://developer.github.com/v3/media/#commits-commit-comparison-and-pull-requests
Expand Down

0 comments on commit 243b7ab

Please sign in to comment.