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

feat(mr update): add --squash-before-merge parameter #856

Merged
merged 2 commits into from
Oct 12, 2021
Merged
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
12 changes: 12 additions & 0 deletions commands/mr/update/mr_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command {
l.RemoveSourceBranch = gitlab.Bool(true)
}

if squashBeforeMerge, _ := cmd.Flags().GetBool("squash-before-merge"); squashBeforeMerge {

if mr.Squash {
actions = append(actions, "disabled squashing of commits before merge")
} else {
actions = append(actions, "enabled squashing of commits before merge")
}

l.Squash = gitlab.Bool(!mr.Squash)
}

fmt.Fprintf(f.IO.StdOut, "- Updating merge request !%d\n", mr.IID)

mr, err = api.UpdateMR(apiClient, repo.FullName(), mr.IID, l)
Expand Down Expand Up @@ -220,6 +231,7 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command {
mrUpdateCmd.Flags().StringSliceP("assignee", "a", []string{}, "assign users via username, prefix with '!' or '-' to remove from existing assignees, '+' to add, otherwise replace existing assignees with given users")
mrUpdateCmd.Flags().StringSliceP("reviewer", "", []string{}, "request review from users by their usernames, prefix with '!' or '-' to remove from existing reviewers, '+' to add, otherwise replace existing reviewers with given users")
mrUpdateCmd.Flags().Bool("unassign", false, "unassign all users")
mrUpdateCmd.Flags().BoolP("squash-before-merge", "", false, "Toggles the option to squash commits into a single commit when merging")
mrUpdateCmd.Flags().BoolP("remove-source-branch", "", false, "Remove Source Branch on merge")
mrUpdateCmd.Flags().StringP("milestone", "m", "", "title of the milestone to assign, pass \"\" or 0 to unassign")
mrUpdateCmd.Flags().String("target-branch", "", "set target branch")
Expand Down