Skip to content

Commit 0c10d67

Browse files
authored
Adding missing field important to find branch in fork from same owner (#2873)
Fixes: #2872.
1 parent 352e4c8 commit 0c10d67

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

example/commitpr/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var (
3838
sourceRepo = flag.String("source-repo", "", "Name of repo to create the commit in.")
3939
commitMessage = flag.String("commit-message", "", "Content of the commit message.")
4040
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")
41+
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")
4142
baseBranch = flag.String("base-branch", "master", "Name of branch to create the `commit-branch` from.")
4243
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.")
4344
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.")
@@ -164,6 +165,7 @@ func createPR() (err error) {
164165
newPR := &github.NewPullRequest{
165166
Title: prSubject,
166167
Head: commitBranch,
168+
HeadRepo: repoBranch,
167169
Base: prBranch,
168170
Body: prDescription,
169171
MaintainerCanModify: github.Bool(true),

github/github-accessors.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/pulls.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ func (s *PullRequestsService) GetRaw(ctx context.Context, owner string, repo str
244244
type NewPullRequest struct {
245245
Title *string `json:"title,omitempty"`
246246
Head *string `json:"head,omitempty"`
247+
HeadRepo *string `json:"head_repo,omitempty"`
247248
Base *string `json:"base,omitempty"`
248249
Body *string `json:"body,omitempty"`
249250
Issue *int `json:"issue,omitempty"`

github/pulls_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ func TestNewPullRequest_Marshal(t *testing.T) {
933933
u := &NewPullRequest{
934934
Title: String("eh"),
935935
Head: String("eh"),
936+
HeadRepo: String("eh"),
936937
Base: String("eh"),
937938
Body: String("eh"),
938939
Issue: Int(1),
@@ -943,6 +944,7 @@ func TestNewPullRequest_Marshal(t *testing.T) {
943944
want := `{
944945
"title": "eh",
945946
"head": "eh",
947+
"head_repo": "eh",
946948
"base": "eh",
947949
"body": "eh",
948950
"issue": 1,

0 commit comments

Comments
 (0)