@@ -11,6 +11,7 @@ import (
1111
1212 "github.com/meinto/glow"
1313 "github.com/pkg/errors"
14+ "github.com/spf13/viper"
1415)
1516
1617type gitlabAdapter struct {
@@ -27,7 +28,7 @@ func (a *gitlabAdapter) Close(b glow.Branch) error {
2728 targets := b .CloseBranches (branchList )
2829
2930 for _ , t := range targets {
30- err := a .createMergeRequest (b , t )
31+ err := a .createMergeRequest (b , t , true )
3132 if err != nil {
3233 return errors .Wrap (err , "error creating merge request" )
3334 }
@@ -41,24 +42,26 @@ func (a *gitlabAdapter) Publish(b glow.Branch) error {
4142 remoteBranchExists := a .gitService .RemoteBranchExists (b .ShortBranchName ())
4243 if b .CanBePublished () && remoteBranchExists == nil {
4344 t := b .PublishBranch ()
44- return a .createMergeRequest (b , t )
45+ return a .createMergeRequest (b , t , false )
4546 }
4647 return errors .Wrap (remoteBranchExists , "cannot be published" )
4748}
4849
49- func (a * gitlabAdapter ) createMergeRequest (source glow.Branch , target glow.Branch ) error {
50+ func (a * gitlabAdapter ) createMergeRequest (source glow.Branch , target glow.Branch , removeSourceBranch bool ) error {
5051 type Payload struct {
5152 SourceBranch string `json:"source_branch"`
5253 TargetBranch string `json:"target_branch"`
5354 Title string `json:"title"`
5455 RemoveSourceBranch bool `json:"remove_source_branch"`
56+ Squash bool `json:"squash"`
5557 }
5658
5759 data := Payload {
5860 SourceBranch : source .ShortBranchName (),
5961 TargetBranch : target .ShortBranchName (),
6062 Title : fmt .Sprintf ("Merge %s in %s" , source .ShortBranchName (), target .ShortBranchName ()),
61- RemoveSourceBranch : false ,
63+ RemoveSourceBranch : removeSourceBranch ,
64+ Squash : viper .GetBool ("mergeRequest.squashCommits" ),
6265 }
6366 payloadBytes , err := json .Marshal (data )
6467 if err != nil {
0 commit comments