Thanks to visit codestin.com
Credit goes to github.com

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
3 changes: 3 additions & 0 deletions api/queries_branch_issue_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ func FindRepoBranchID(client *Client, repo ghrepo.Interface, ref string) (string

branchID := query.Repository.Ref.Target.Oid
if branchID == "" {
if ref != "" {
return "", "", fmt.Errorf("could not find branch %q in %s", ref, ghrepo.FullName(repo))
}
branchID = query.Repository.DefaultBranchRef.Target.Oid
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/issue/develop/develop.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func NewCmdDevelop(f *cmdutil.Factory, runF func(*DevelopOptions) error) *cobra.

fl := cmd.Flags()
fl.StringVar(&opts.BranchRepo, "branch-repo", "", "Name or URL of the repository where you want to create your new branch")
fl.StringVarP(&opts.BaseBranch, "base", "b", "", "Name of the base branch you want to make your new branch from")
fl.StringVarP(&opts.BaseBranch, "base", "b", "", "Name of the remote branch you want to make your new branch from")
fl.BoolVarP(&opts.Checkout, "checkout", "c", false, "Checkout the branch after creating it")
fl.BoolVarP(&opts.List, "list", "l", false, "List linked branches for the issue")
fl.StringVarP(&opts.Name, "name", "n", "", "Name of the branch to create")
Expand Down
25 changes: 25 additions & 0 deletions pkg/cmd/issue/develop/develop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,31 @@ func TestDevelopRun(t *testing.T) {
},
expectedOut: "github.com/OWNER/REPO/tree/my-branch\n",
},
{
name: "develop with base branch which does not exist",
opts: &DevelopOptions{
IssueSelector: "123",
BaseBranch: "does-not-exist-branch",
},
remotes: map[string]string{
"origin": "OWNER/REPO",
},
httpStubs: func(reg *httpmock.Registry, t *testing.T) {
reg.Register(
httpmock.GraphQL(`query LinkedBranchFeature\b`),
httpmock.StringResponse(featureEnabledPayload),
)
reg.Register(
httpmock.GraphQL(`query IssueByNumber\b`),
httpmock.StringResponse(`{"data":{"repository":{"hasIssuesEnabled":true,"issue":{"id": "SOMEID","number":123,"title":"my issue"}}}}`),
)
reg.Register(
httpmock.GraphQL(`query FindRepoBranchID\b`),
httpmock.StringResponse(`{"data":{"repository":{"id":"REPOID","defaultBranchRef":{"target":{"oid":"DEFAULTOID"}},"ref":null}}}`),
)
},
wantErr: "could not find branch \"does-not-exist-branch\" in OWNER/REPO",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down