Repository: cli/cli
File: pkg/cmd/pr/create/create.go (Go)

Code before:
	fl.StringVarP(&opts.Milestone, "milestone", "m", "", "Add the pull request to a milestone by `name`")
	fl.Bool("no-maintainer-edit", false, "Disable maintainer's ability to modify pull request")
	fl.StringVar(&opts.RecoverFile, "recover", "", "Recover input from a failed run of create")
	fl.StringVarP(&opts.Template, "template", "T", "", "Template `file` to use as starting body text")
	fl.BoolVar(&opts.DryRun, "dry-run", false, "Print details instead of creating the PR. May still push git changes.")

	_ = cmdutil.RegisterBranchCompletionFlags(f.GitClient, cmd, "base", "head")

	_ = cmd.RegisterFlagCompletionFunc("reviewer", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		results, err := requestableReviewersForCompletion(opts)
		if err != nil {
			return nil, cobra.ShellCompDirectiveError
		}
		return results, cobra.ShellCompDirectiveNoFileComp
	})

	return cmd
}

func createRun(opts *CreateOptions) error {
	ctx, err := NewCreateContext(opts)
	if err != nil {
		return err
	}

	// Check if head and base refs point to the same ref in the same repository
	if isSameRef(ctx.PRRefs) {
		return fmt.Errorf("head branch %q is the same as base branch %q, cannot create a pull request", ctx.PRRefs.UnqualifiedHeadRef(), ctx.PRRefs.BaseRef())
	}

	httpClient, err := opts.HttpClient()
	if err != nil {
		return err
	}

	// TODO projectsV1Deprecation
	// Remove this section as we should no longer need to detect
	if opts.Detector == nil {
		cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
		opts.Detector = fd.NewDetector(cachedClient, ctx.PRRefs.BaseRepo().RepoHost())
	}

	projectsV1Support := opts.Detector.ProjectsV1()

	client := ctx.Client

	state, err := NewIssueState(*ctx, *opts)
	if err != nil {
		return err
	}


Review comment (suggestion):
Nit: Sort of the same as above, I think it's self-describing. We can clean it up a bit.

```suggestion
```

Code after:
	fl.StringVarP(&opts.Template, "template", "T", "", "Template `file` to use as starting body text")
	fl.BoolVar(&opts.DryRun, "dry-run", false, "Print details instead of creating the PR. May still push git changes.")

	_ = cmdutil.RegisterBranchCompletionFlags(f.GitClient, cmd, "base", "head")

	_ = cmd.RegisterFlagCompletionFunc("reviewer", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		results, err := requestableReviewersForCompletion(opts)
		if err != nil {
			return nil, cobra.ShellCompDirectiveError
		}
		return results, cobra.ShellCompDirectiveNoFileComp
	})

	return cmd
}

func createRun(opts *CreateOptions) error {
	ctx, err := NewCreateContext(opts)
	if err != nil {
		return err
	}

	if isSameRef(ctx.PRRefs) {
		return fmt.Errorf("head branch %q is the same as base branch %q, cannot create a pull request", ctx.PRRefs.UnqualifiedHeadRef(), ctx.PRRefs.BaseRef())
	}

	httpClient, err := opts.HttpClient()
	if err != nil {
		return err
	}

	// TODO projectsV1Deprecation
	// Remove this section as we should no longer need to detect
	if opts.Detector == nil {
		cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
		opts.Detector = fd.NewDetector(cachedClient, ctx.PRRefs.BaseRepo().RepoHost())
	}

	projectsV1Support := opts.Detector.ProjectsV1()

	client := ctx.Client

	state, err := NewIssueState(*ctx, *opts)
	if err != nil {
		return err
	}

	var openURL string

	if opts.WebMode {
		if !(opts.Autofill || opts.FillFirst) {