Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Web for mr #566

Merged
merged 2 commits into from
Jan 14, 2021
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
13 changes: 13 additions & 0 deletions commands/issue/create/issue_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type CreateOpts struct {
IsInteractive bool
OpenInWeb bool
Yes bool
Web bool

IO *utils.IOStreams
BaseRepo func() (glrepo.Interface, error)
Expand All @@ -63,6 +64,7 @@ func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
$ glab issue new
$ glab issue create -m release-2.0.0 -t "we need this feature" --label important
$ glab issue new -t "Fix CVE-YYYY-XXXX" -l security --linked-mr 123
$ glab issue create -m release-1.0.1 -t "security fix" --label security --web
`),
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -95,6 +97,12 @@ func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
return &cmdutils.FlagError{Err: errors.New("--title and --description required for non-interactive mode")}
}

// Remove this once --yes does more than just skip the prompts that --web happen to skip
// by design
if opts.Yes && opts.Web {
return &cmdutils.FlagError{Err: errors.New("--web already skips all prompts currently skipped by --yes")}
}

opts.BaseProject, err = api.GetProject(apiClient, repo.FullName())
if err != nil {
return err
Expand All @@ -118,6 +126,7 @@ func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
issueCreateCmd.Flags().IntVarP(&opts.Weight, "weight", "w", 0, "The weight of the issue. Valid values are greater than or equal to 0.")
issueCreateCmd.Flags().BoolVarP(&opts.NoEditor, "no-editor", "", false, "Don't open editor to enter description. If set to true, uses prompt. Default is false")
issueCreateCmd.Flags().BoolVarP(&opts.Yes, "yes", "y", false, "Don't prompt for confirmation to submit the issue")
issueCreateCmd.Flags().BoolVar(&opts.Web, "web", false, "continue issue creation with web interface")

return issueCreateCmd
}
Expand Down Expand Up @@ -220,6 +229,10 @@ func createRun(opts *CreateOpts) error {
action = cmdutils.SubmitAction
}

if opts.Web {
action = cmdutils.PreviewAction
}

if action == cmdutils.NoAction {
action, err = cmdutils.ConfirmSubmission(true, true)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions commands/mr/create/mr_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type CreateOpts struct {
NoEditor bool
IsInteractive bool
Yes bool
Web bool

IO *utils.IOStreams
Branch func() (string, error)
Expand Down Expand Up @@ -119,6 +120,11 @@ func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
if cmd.Flags().Changed("wip") && cmd.Flags().Changed("draft") {
return &cmdutils.FlagError{Err: errors.New("specify either of --draft or --wip")}
}
// Remove this once --yes does more than just skip the prompts that --web happen to skip
// by design
if opts.Yes && opts.Web {
return &cmdutils.FlagError{Err: errors.New("--web already skips all prompts currently skipped by --yes")}
}

labClient, err := opts.Lab()
if err != nil {
Expand Down Expand Up @@ -331,6 +337,10 @@ func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
action = cmdutils.SubmitAction
}

if opts.Web {
action = cmdutils.PreviewAction
}

if action == cmdutils.NoAction {
action, err = cmdutils.ConfirmSubmission(true, true)
if err != nil {
Expand Down Expand Up @@ -445,6 +455,7 @@ func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
mrCreateCmd.Flags().BoolVarP(&opts.NoEditor, "no-editor", "", false, "Don't open editor to enter description. If set to true, uses prompt. Default is false")
mrCreateCmd.Flags().StringP("head", "H", "", "Select another head repository using the `OWNER/REPO` or `GROUP/NAMESPACE/REPO` format or the project ID or full URL")
mrCreateCmd.Flags().BoolVarP(&opts.Yes, "yes", "y", false, "Skip submission confirmation prompt, with --autofill it skips all optional prompts")
mrCreateCmd.Flags().BoolVarP(&opts.Web, "web", "w", false, "continue merge request creation on web browser")

mrCreateCmd.Flags().StringVarP(&mrCreateTargetProject, "target-project", "", "", "Add target project by id or OWNER/REPO or GROUP/NAMESPACE/REPO")
mrCreateCmd.Flags().MarkHidden("target-project")
Expand Down