Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions api/fake_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ func (f *FakeHTTP) StubRepoResponse(owner, repo string) {
"name": "%s",
"owner": {"login": "%s"},
"defaultBranchRef": {
"name": "master",
"target": {"oid": "deadbeef"}
"name": "master"
},
"viewerPermission": "WRITE"
} } }
Expand All @@ -76,17 +75,15 @@ func (f *FakeHTTP) StubForkedRepoResponse(forkFullName, parentFullName string) {
"name": "%s",
"owner": {"login": "%s"},
"defaultBranchRef": {
"name": "master",
"target": {"oid": "deadbeef"}
"name": "master"
},
"viewerPermission": "ADMIN",
"parent": {
"id": "REPOID1",
"name": "%s",
"owner": {"login": "%s"},
"defaultBranchRef": {
"name": "master",
"target": {"oid": "deadbeef"}
"name": "master"
},
"viewerPermission": "READ"
}
Expand Down
6 changes: 1 addition & 5 deletions api/queries_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ type Repository struct {
HasIssuesEnabled bool
ViewerPermission string
DefaultBranchRef struct {
Name string
Target struct {
OID string
}
Name string
}

Parent *Repository
Expand Down Expand Up @@ -127,7 +124,6 @@ func RepoNetwork(client *Client, repos []ghrepo.Interface) (RepoNetworkResult, e
viewerPermission
defaultBranchRef {
name
target { oid }
}
isPrivate
}
Expand Down
6 changes: 5 additions & 1 deletion command/pr_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ func prCreate(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("could not parse body: %w", err)
}

defs, defaultsErr := computeDefaults(baseBranch, headBranch)
baseTrackingBranch := baseBranch
if baseRemote, err := remotes.FindByRepo(baseRepo.RepoOwner(), baseRepo.RepoName()); err == nil {
baseTrackingBranch = fmt.Sprintf("%s/%s", baseRemote.Name, baseBranch)
}
defs, defaultsErr := computeDefaults(baseTrackingBranch, headBranch)

isWeb, err := cmd.Flags().GetBool("web")
if err != nil {
Expand Down
13 changes: 5 additions & 8 deletions command/pr_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ func TestPRCreate_cross_repo_same_branch(t *testing.T) {
"name": "REPO",
"owner": {"login": "OWNER"},
"defaultBranchRef": {
"name": "default",
"target": {"oid": "deadbeef"}
"name": "default"
},
"viewerPermission": "READ"
},
Expand All @@ -226,17 +225,15 @@ func TestPRCreate_cross_repo_same_branch(t *testing.T) {
"name": "REPO",
"owner": {"login": "OWNER"},
"defaultBranchRef": {
"name": "default",
"target": {"oid": "deadbeef"}
"name": "default"
},
"viewerPermission": "READ"
},
"id": "REPOID1",
"name": "REPO",
"owner": {"login": "MYSELF"},
"defaultBranchRef": {
"name": "default",
"target": {"oid": "deadbeef"}
"name": "default"
},
"viewerPermission": "WRITE"
} } }
Expand Down Expand Up @@ -514,7 +511,7 @@ func TestPRCreate_defaults_error_autofill(t *testing.T) {

_, err := RunCommand(prCreateCmd, "pr create -f")

eq(t, err.Error(), "could not compute title or body defaults: could not find any commits between master and feature")
eq(t, err.Error(), "could not compute title or body defaults: could not find any commits between origin/master and feature")
}

func TestPRCreate_defaults_error_web(t *testing.T) {
Expand All @@ -532,7 +529,7 @@ func TestPRCreate_defaults_error_web(t *testing.T) {

_, err := RunCommand(prCreateCmd, "pr create -w")

eq(t, err.Error(), "could not compute title or body defaults: could not find any commits between master and feature")
eq(t, err.Error(), "could not compute title or body defaults: could not find any commits between origin/master and feature")
}

func TestPRCreate_defaults_error_interactive(t *testing.T) {
Expand Down