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

Commit

Permalink
Merge pull request #855 from pataar/patch-3
Browse files Browse the repository at this point in the history
feat(mr create): add `--squash-before-merge` parameter
  • Loading branch information
profclems authored Oct 4, 2021
2 parents d8dc78b + 977e830 commit 3d9f97c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions commands/mr/create/mr_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type CreateOpts struct {
CreateSourceBranch bool
RemoveSourceBranch bool
AllowCollaboration bool
SquashBeforeMerge bool

Autofill bool
FillCommitBody bool
Expand Down Expand Up @@ -157,6 +158,7 @@ func NewCmdCreate(f *cmdutils.Factory, runE func(opts *CreateOpts) error) *cobra
mrCreateCmd.Flags().StringVarP(&opts.MilestoneFlag, "milestone", "m", "", "The global ID or title of a milestone to assign")
mrCreateCmd.Flags().BoolVarP(&opts.AllowCollaboration, "allow-collaboration", "", false, "Allow commits from other members")
mrCreateCmd.Flags().BoolVarP(&opts.RemoveSourceBranch, "remove-source-branch", "", false, "Remove Source Branch on merge")
mrCreateCmd.Flags().BoolVarP(&opts.SquashBeforeMerge, "squash-before-merge", "", false, "Squash commits into a single commit when merging")
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 --fill it skips all optional prompts")
Expand Down Expand Up @@ -354,12 +356,19 @@ func createRun(opts *CreateOpts) error {
mrCreateOpts.Description = gitlab.String(opts.Description)
mrCreateOpts.SourceBranch = gitlab.String(opts.SourceBranch)
mrCreateOpts.TargetBranch = gitlab.String(opts.TargetBranch)

if opts.AllowCollaboration {
mrCreateOpts.AllowCollaboration = gitlab.Bool(true)
}

if opts.RemoveSourceBranch {
mrCreateOpts.RemoveSourceBranch = gitlab.Bool(true)
}

if opts.SquashBeforeMerge {
mrCreateOpts.Squash = gitlab.Bool(true)
}

if opts.TargetProject != nil {
mrCreateOpts.TargetProjectID = gitlab.Int(opts.TargetProject.ID)
}
Expand Down

0 comments on commit 3d9f97c

Please sign in to comment.