diff --git a/pkg/cmd/pr/create/create.go b/pkg/cmd/pr/create/create.go index 25e34c9e4..4efdad799 100644 --- a/pkg/cmd/pr/create/create.go +++ b/pkg/cmd/pr/create/create.go @@ -61,7 +61,7 @@ type CreateContext struct { // This struct stores contextual data about the creation process and is for building up enough // data to create a pull request RepoContext *context.ResolvedRemotes - BaseRepo ghrepo.Interface + BaseRepo *api.Repository HeadRepo ghrepo.Interface BaseTrackingBranch string BaseBranch string @@ -264,7 +264,7 @@ func createRun(opts *CreateOptions) (err error) { } } - allowMetadata := ctx.BaseRepo.(*api.Repository).ViewerCanTriage() + allowMetadata := ctx.BaseRepo.ViewerCanTriage() action, err := shared.ConfirmSubmission(!state.HasMetadata(), allowMetadata) if err != nil { return fmt.Errorf("unable to confirm: %w", err) @@ -597,7 +597,7 @@ func submitPR(opts CreateOptions, ctx CreateContext, state shared.IssueMetadataS } opts.IO.StartProgressIndicator() - pr, err := api.CreatePullRequest(client, ctx.BaseRepo.(*api.Repository), params) + pr, err := api.CreatePullRequest(client, ctx.BaseRepo, params) opts.IO.StopProgressIndicator() if pr != nil { fmt.Fprintln(opts.IO.Out, pr.URL) diff --git a/pkg/cmd/pr/create/create_test.go b/pkg/cmd/pr/create/create_test.go index 58e536d59..4c604875b 100644 --- a/pkg/cmd/pr/create/create_test.go +++ b/pkg/cmd/pr/create/create_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/MakeNowJust/heredoc" + "github.com/cli/cli/api" "github.com/cli/cli/context" "github.com/cli/cli/git" "github.com/cli/cli/internal/config" @@ -873,7 +874,7 @@ func Test_generateCompareURL(t *testing.T) { { name: "basic", ctx: CreateContext{ - BaseRepo: ghrepo.New("OWNER", "REPO"), + BaseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"), BaseBranch: "main", HeadBranchLabel: "feature", }, @@ -883,7 +884,7 @@ func Test_generateCompareURL(t *testing.T) { { name: "with labels", ctx: CreateContext{ - BaseRepo: ghrepo.New("OWNER", "REPO"), + BaseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"), BaseBranch: "a", HeadBranchLabel: "b", }, @@ -896,7 +897,7 @@ func Test_generateCompareURL(t *testing.T) { { name: "complex branch names", ctx: CreateContext{ - BaseRepo: ghrepo.New("OWNER", "REPO"), + BaseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"), BaseBranch: "main/trunk", HeadBranchLabel: "owner:feature", },