Skip to content

Commit

Permalink
Adding missing field important to find branch in fork from same owner (
Browse files Browse the repository at this point in the history
…#2873)

Fixes: #2872.
  • Loading branch information
r-aramizu authored Aug 15, 2023
1 parent 352e4c8 commit 0c10d67
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions example/commitpr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (
sourceRepo = flag.String("source-repo", "", "Name of repo to create the commit in.")
commitMessage = flag.String("commit-message", "", "Content of the commit message.")
commitBranch = flag.String("commit-branch", "", "Name of branch to create the commit in. If it does not already exists, it will be created using the `base-branch` parameter")
repoBranch = flag.String("repo-branch", "", "Name of the repository where the changes in the pull request were made. This field is required for cross-repository pull requests if both repositories are owned by the same organization")
baseBranch = flag.String("base-branch", "master", "Name of branch to create the `commit-branch` from.")
prRepoOwner = flag.String("merge-repo-owner", "", "Name of the owner (user or org) of the repo to create the PR against. If not specified, the value of the `-source-owner` flag will be used.")
prRepo = flag.String("merge-repo", "", "Name of repo to create the PR against. If not specified, the value of the `-source-repo` flag will be used.")
Expand Down Expand Up @@ -164,6 +165,7 @@ func createPR() (err error) {
newPR := &github.NewPullRequest{
Title: prSubject,
Head: commitBranch,
HeadRepo: repoBranch,
Base: prBranch,
Body: prDescription,
MaintainerCanModify: github.Bool(true),
Expand Down
8 changes: 8 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions github/pulls.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func (s *PullRequestsService) GetRaw(ctx context.Context, owner string, repo str
type NewPullRequest struct {
Title *string `json:"title,omitempty"`
Head *string `json:"head,omitempty"`
HeadRepo *string `json:"head_repo,omitempty"`
Base *string `json:"base,omitempty"`
Body *string `json:"body,omitempty"`
Issue *int `json:"issue,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions github/pulls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ func TestNewPullRequest_Marshal(t *testing.T) {
u := &NewPullRequest{
Title: String("eh"),
Head: String("eh"),
HeadRepo: String("eh"),
Base: String("eh"),
Body: String("eh"),
Issue: Int(1),
Expand All @@ -943,6 +944,7 @@ func TestNewPullRequest_Marshal(t *testing.T) {
want := `{
"title": "eh",
"head": "eh",
"head_repo": "eh",
"base": "eh",
"body": "eh",
"issue": 1,
Expand Down

0 comments on commit 0c10d67

Please sign in to comment.